UIAlertController设置
2016-05-03 09:37
621 查看
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *alertAction){
NSLog(@"如果你是iOS8以上的应用,这个适合你,简单明了");
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
1. [self presentViewController:alertController animated:YES completion:nil];
2.[alertController.view setNeedsLayout];
以上两个必须写一个,不然会报错:Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7f84e25b22b0>)
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *alertAction){
NSLog(@"如果你是iOS8以上的应用,这个适合你,简单明了");
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
1. [self presentViewController:alertController animated:YES completion:nil];
2.[alertController.view setNeedsLayout];
以上两个必须写一个,不然会报错:Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7f84e25b22b0>)
相关文章推荐
- Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted
- iOS开发—— UIMenuController的使用
- LeetCode "Top K Frequent Elements"
- 【Arduino官方教程第一辑】示例程序 2-8 曲调2
- 【Arduino官方教程第一辑】示例程序 2-7 使用tone()函数弹奏一段小曲
- google base 之MessagePumpForUI
- bzoj 1345: [Baltic2007]序列问题Sequence(单调栈)
- Elasticsearch源码分析之一——使用Guice进行依赖注入与模块化系统
- LeetCode 270: Closest Binary Search Tree Value
- google base之IncomingTaskQueue
- 知问前端——日历UI(二)
- 纠结的名字 - 自动生成apk文件名
- The version of Gradle requested by the project.
- UICollectionView基本使用
- [BZOJ1345][Baltic2007]序列问题Sequence(单调栈)
- 读取日志文件,搜索关键字,打印关键字前5行。yield、deque实例
- 建造者(Builder)模式
- 知问前端——日历UI(一)
- Android 中文翻译:Build System Overview
- 新书到手 TRANSACTION PROCESSING:CONCEPTS AND TECHNIQUES