【UIKit】-9-UIAlertController - IOS8 包括 alert 和 sheet
2015-07-22 12:50
645 查看
参考 http://www.cocoachina.com/ios/20141126/10320.html http://blog.csdn.net/liangliang103377/article/details/40078015 http://www.cocoachina.com/ios/20141219/10701.html
A UIAlertController object displays an alert message to the user. This class replaces the UIActionSheet and UIAlertView classes for displaying alerts. After configuring the alert controller with the actions
and style you want, present it using the presentViewController:animated:completion: method. In addition to displaying a message to a user, you can associate actions with your alert controller to give the user a way to respond. For each action you add using
the addAction: method, the alert controller configures a button with the action details. When the user taps that action, the alert controller executes the block you provided when creating the action object. Listing 1 shows how to configure an alert with a
single action.
一个UIAlertController对象显示一个警告信息给用户。该类取代UIActionSheet和UIAlertView类显示警报。配置你想要的动作和风格报警控制器后,使用presentViewController目前它:动画:完成:方法。除了显示一个消息给用户,你可以行动,您的警报控制器关联到给用户的方式来回应。对于每一个动作您添加使用的addAction:方法,警报控制器配置与操作的详细信息按钮。当用户点击该动作时,警报控制器执行创建操作对象时,你所提供的块。清单1显示了如何配置一个警报,一个动作。
简单使用,
UIAlertController *alc = [UIAlertController
alertControllerWithTitle:@"title"
message:@"message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel =[UIAlertAction
actionWithTitle:@"cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) {
NSLog(@"cancel");
}];
UIAlertAction *ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"ok");
}];
UIAlertAction *ok2 = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"ok2");
}];
[alc addAction:cancel];
[alc addAction:ok];
[alc addAction:ok2];
[self
presentViewController:alc animated:YES
completion:nil];
A UIAlertController object displays an alert message to the user. This class replaces the UIActionSheet and UIAlertView classes for displaying alerts. After configuring the alert controller with the actions
and style you want, present it using the presentViewController:animated:completion: method. In addition to displaying a message to a user, you can associate actions with your alert controller to give the user a way to respond. For each action you add using
the addAction: method, the alert controller configures a button with the action details. When the user taps that action, the alert controller executes the block you provided when creating the action object. Listing 1 shows how to configure an alert with a
single action.
一个UIAlertController对象显示一个警告信息给用户。该类取代UIActionSheet和UIAlertView类显示警报。配置你想要的动作和风格报警控制器后,使用presentViewController目前它:动画:完成:方法。除了显示一个消息给用户,你可以行动,您的警报控制器关联到给用户的方式来回应。对于每一个动作您添加使用的addAction:方法,警报控制器配置与操作的详细信息按钮。当用户点击该动作时,警报控制器执行创建操作对象时,你所提供的块。清单1显示了如何配置一个警报,一个动作。
简单使用,
UIAlertController *alc = [UIAlertController
alertControllerWithTitle:@"title"
message:@"message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel =[UIAlertAction
actionWithTitle:@"cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) {
NSLog(@"cancel");
}];
UIAlertAction *ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"ok");
}];
UIAlertAction *ok2 = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"ok2");
}];
[alc addAction:cancel];
[alc addAction:ok];
[alc addAction:ok2];
[self
presentViewController:alc animated:YES
completion:nil];
相关文章推荐
- 【UIkit】-8-UIActionSheet - 底部弹出提示,快要被取代
- 思维题 HDOJ 5288 OO’s Sequence
- [tableView reloadData]方法添加动画的方法
- C#使用队列(Queue)解决简单的并发问题
- 使用Arduino与A4988 驱动步进电机
- Android异步处理三:Handler+Looper+MessageQueue深入详解
- Android异步处理二:使用AsyncTask异步更新UI界面
- Android异步处理一:使用Thread+Handler实现非UI线程更新UI界面
- easy-ui
- zoj 1649 Rescue bfs
- 【UIKit】-5,6,7-UIActivity - 系统服务,社交信息等
- 几个交互设计的原则
- The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....
- Android学习笔记之——Notification.Builder类的用法
- [转]Failed to run the WC DB work queue associated with 错误的解决
- 关于ueditor在javaweb项目中的集成
- poj 2299 Ultra-QuickSort 二分+线段树求逆序数
- hdu 5288 OO’s Sequence(2015 Multi-University Training Contest 1)
- 【UIKit】-4-UIActivityIndicatorView - 系统转菊花
- HDU 5288 OO’s Sequence (二分)2015多校训练一