iOS开发---“弹框”
1、一、UIAlertView (但在ios9以后已经不在提倡此方法)随着苹果上次iOS 5的发布,对话框视图样式出现在了我们面前,直到现在它都没有发生过很大的变化。下面的代码片段展示了如何初始化和显示一个带有“取消”和“好的”按钮的对话框视图。//提示样式(4种)@property(nonatomic,assign) UIAlertViewStyle alertViewStyle//UIAlertViewStyleDefault ---默认样式//UIAlertViewStyleSecureTextInput ---带有Password输入框//UIAlertViewStylePlainTextInput ---输入框// UIAlertViewStyleLoginAndPasswordInput --Login和Password的输入框1.只有“确定” “取消” 两个按钮 默认样式为UIAlertViewStyleDefault//排列 取消--0 确定--1UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示"message:@"确认退出登录?"delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];alert.alertViewStyle=UIAlertViewStyleDefault; //显示样式[alert show]; //提示框显示//===点击后执行的方法===#pragma mark-----UIAlertViewDelegate 使用UIAlertView时 遵循的协议--//UIAlertViewDelegate 使用UIAlertView时 遵循的协议- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) { //取消 [alertView dismissWithClickedButtonIndex:0 animated:YES]; NSLog(@"点击了取消按钮"); }else if (buttonIndex == 1){ //确定 NSLog(@"点击了确定按钮"); }}


2、2.有多个按钮的提示框//@"取消" @"确定",@"AA",@"BB", 排列--0 1 2 3//UIAlertViewDelegate 使用UIAlertView时 遵循的协议 有回调方法 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示"message:@"确认退出登录?"delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"确定",@"AA",@"BB",nil]; alert.alertViewStyle=UIAlertViewStyleDefault; [alert show];



5、2.UIAlertController 和 UIAlertAction 一起使用typedef NS_ENUM(NSInteger, UIAlertActionStyle) { UIAlertActionStyleDefault = 0, //默认 UIAlertActionStyleCancel, //在左边 不能同时设置2个) UIAlertActionStyleDestructive //变为红色} NS_ENUM_AVAILABLE_IOS(8_0);UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"你确定退出?" message:nil preferredStyle:UIAlertControllerStyleAlert]; //UIAlertActionStyleDefault //UIAlertActionStyleCancel //在左边 (不能同时设置2个) //UIAlertActionStyleDestructive //变为红色 //确定 UIAlertAction *okAlert = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ //具体操作内容 }]; //取消 UIAlertAction *cancelAlert = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action){ //具体操作内容 }]; [alert addAction:okAlert]; [alert addAction:cancelAlert]; [self presentViewController:alert animated:YES completion:nil];

7、====UIActivityIndicatorView(菊花/指示器)====代码如下图
