UIAlertController 的简单使用方法
2016-01-08 12:03
495 查看
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake(10, 60, 80, 30);
[btn setTitle:@"提示框" forState:UIControlStateNormal];
btn.backgroundColor=[UIColor redColor];
[btn addTarget:self action:@selector(gotoAlertVC) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
-(void)gotoAlertVC{
UIAlertController *alertVC=[UIAlertController alertControllerWithTitle:@"提示信息" message:@"iOSQQ技术交流群436337987" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"确定加入");
}];
UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"取消加入");
}];
[alertVC addAction:sureAction];
[alertVC addAction:cancelAction];
[self presentViewController:alertVC animated:YES completion:nil];
}
[super viewDidLoad];
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake(10, 60, 80, 30);
[btn setTitle:@"提示框" forState:UIControlStateNormal];
btn.backgroundColor=[UIColor redColor];
[btn addTarget:self action:@selector(gotoAlertVC) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
-(void)gotoAlertVC{
UIAlertController *alertVC=[UIAlertController alertControllerWithTitle:@"提示信息" message:@"iOSQQ技术交流群436337987" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"确定加入");
}];
UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"取消加入");
}];
[alertVC addAction:sureAction];
[alertVC addAction:cancelAction];
[self presentViewController:alertVC animated:YES completion:nil];
}
相关文章推荐
- UILabel ,UITextView设置行间距
- 程序员面试问题2:矩阵区域和 Programming Interview Questions 2: Matrix Region Sum
- (java)Range Sum Query - Immutable
- Android TextView 跑马灯效果 android:ellipsize="marquee"
- Win7 Ubuntu双系统,删除并格式化Ubuntu分区后,启动出现grub rescue的解决方法
- uinput的使用
- UITextField文本框详解
- 1.2.0 Quickstart: "Hello World"(快速开始:“你好世界!”)
- 关于CC2540/2541编译Performing Post-Build Action卡住的问题
- iOS UISearchBar 和 UISearchDisplayController的使用
- ios UITableView 滑动 headerView footerView 跟随问题
- UIImage图片处理
- 输出字典中的key和 value
- 年结Close Process的两支Request
- mysql导入报错Variable 'sql_notes' can't be set to the value of 'NULL'
- 显示和隐藏easyui combobox
- 响应式web设计之CSS3 Media Queries
- EasyUI验证扩展
- Sql server 数据库 int 和guid 两者的比较
- UILabel关于支持HTML格式 自动换行 行间距的封装