IOS--UIAlertView的使用方法详细
IOS--UIAlertView的使用方法詳細
?????// UIAlertView的常用方法
????//?標準樣式
????UIAlertView?*oneAlertView = [[UIAlertView?alloc]?initWithTitle:@"標題"message:@"提示內容"?delegate:self?cancelButtonTitle:@"關閉"otherButtonTitles:@"OK",?nil];
????[oneAlertView?show];?//?顯示出來
????[oneAlertView?release], oneAlertView =?nil;?//?釋放內存
?
????oneAlertView.alertViewStyle?=?UIAlertViewStyleDefault;?//?設置oneAlerView的樣式
//????UIAlertViewStyleDefault?只彈信息和按鈕
//????UIAlertViewStyleSecureTextInput?有一個textfield加密框
//????UIAlertViewStylePlainTextInput?有一個不加密的textfield
//????UIAlertViewStyleLoginAndPasswordInput?有兩個textfield,Login和password
?
?
?
//?按鈕橫排顯示
????UIAlertView?*twoAlertView = [[UIAlertView?alloc]?initWithTitle:@"標題"message:@"提示內容"?delegate:self?cancelButtonTitle:@"關閉"?otherButtonTitles:@"按鈕1",?@"按鈕2",?@"按鈕2",?nil];
????[twoAlertView?show]; //?顯示出來
????[twoAlertView?release], twoAlertView =?nil; //?釋放內存
// 添加了多個按鈕,那么要怎么判斷我們按下的是哪個按鈕呢?
// 需要在.h文件中實現UIAlertViewDelegate代理,然后在.m文件中重寫下面的方法
?
#pragma mark -?實現UIAlertView的代理方法判斷按了哪個按鈕
- (void)alertView:(UIAlertView?*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
????//?獲取您按下的是哪個按鈕
????NSString* msg = [[NSString?alloc]?initWithFormat:@"您按下的第%d個按鈕!",buttonIndex];
????NSLog(@"%@", msg);
????[msg?release], msg =?nil;
????//?點擊“取消”,“按鈕1”,“按鈕2”,“按鈕3”的索引buttonIndex分別是0,1,2,3
}
?
?
?
?
????//?給UIAlertView添加其他
????UIAlertView*alert = [[UIAlertView?alloc]initWithTitle:@"請等待"
??????????????????????????????????????????????????message:nil
?????????????????????????????????????????????????delegate:nil
????????????????????????????????????????cancelButtonTitle:nil
????????????????????????????????????????otherButtonTitles:nil];
????[alert?show];
????UIActivityIndicatorView?*activeView = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
????activeView.center?=?CGPointMake(alert.bounds.size.width/2.0f, alert.bounds.size.height-40.0f);
????[activeView?startAnimating];
????[alert?addSubview:activeView];
????[activeView?release];
????[alert?release];
?
// 還有很多方法,想深入了解的可以查看api自己慢慢試試。這些基本夠用了。。。
?
轉載于:https://www.cnblogs.com/iOS-mt/p/4147804.html
總結
以上是生活随笔為你收集整理的IOS--UIAlertView的使用方法详细的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: windows 10 markdown
- 下一篇: Qt5下载安装及环境变量配置详解