ios基本控件之UIAlertController
2016-06-16 14:59
316 查看
在IOS8以后我们就可以用这个UIAlertController了,本人感觉用惯了UIAlertView,还真的有点不习惯这个 UIAlertController,所以自己用警告狂的时候基本用的都还是 UIAlertView,可是在IOS9之后这个UIAlertView就要被放弃了,昨天IOS10刚出来,那我现在就得把项目中自己用到的这个UI AlertView 修改成这个controller了,今天在用的时候,我发现给这个controller添加事件的时候取消永远是在前边,这看着会不会太奇葩了,
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//do sure action
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//do cancel action
}];
[alertController addAction:sureAction];
[alertController addAction:cancelAction];
这样的话,取消在前边,如下图:
好吧 奇葩,所以我想着是不是这个cancel有问题,所以我这么写:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告" message:@"输入数值不符合规则,请重新输入" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//do sure action
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//do cancel action
}];
[alertController addAction:sureAction];
[alertController addAction:cancelAction];
[self.viewController presentViewController:alertController animated:YES completion:^{
}];
还真是,解决了问题:
以后得用这个AlertController,就像我之前写的关于App Store 的IPV6的事中的一句话,真是苹果打了哈欠,我们就感觉地动山摇啊。不关注苹果动向,随时的API可能就不能用了。
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//do sure action
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//do cancel action
}];
[alertController addAction:sureAction];
[alertController addAction:cancelAction];
这样的话,取消在前边,如下图:
好吧 奇葩,所以我想着是不是这个cancel有问题,所以我这么写:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告" message:@"输入数值不符合规则,请重新输入" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//do sure action
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//do cancel action
}];
[alertController addAction:sureAction];
[alertController addAction:cancelAction];
[self.viewController presentViewController:alertController animated:YES completion:^{
}];
还真是,解决了问题:
以后得用这个AlertController,就像我之前写的关于App Store 的IPV6的事中的一句话,真是苹果打了哈欠,我们就感觉地动山摇啊。不关注苹果动向,随时的API可能就不能用了。
相关文章推荐
- web.xml is missing and <failOnMissingWebXml> is set to true
- RF《Quick Start Guide》操作总结
- D001-开发工具-Protel99SE-配置-常用技巧-快捷键-(ques=1)
- Arduino 和 TB6612FNG 驱动直流电机
- UISearchController:遮挡UITableView
- confluence-5.4.4安装、破解、汉化
- nib but didn't get a UITableView
- UITableView基础
- 将UIImage保存成JPG或PNG格式存储在本地
- UI Automator
- 解决UIButton 选中状态和未选中状态色差问题
- SoapUI - 全局变量的使用
- CUICatalog: Invalid asset name supplied:
- UITextField使用总结
- Android Guide
- NSTimer UUID
- UI Design
- iOS8使用UIVisualEffectView实现模糊效果
- IOS开发-UIView之动画效果的实现方法(合集)
- Uiautomator向jar包传多个参数