ios8下,alertController之初体验
来源:互联网 发布:格式化后数据还能恢复吗 编辑:程序博客网 时间:2024/06/01 10:05
ios8之前,针对弹出消息,一般使用的都是UAlertView,UIActionSheet。无论是在pad,还是phone设备下,使用起来都是非常方便的。
但是ios8出来后,原来的项目适配ios8的情况下,发现UIActionSheet不好用了,查看苹果的官方文档发现,UIActionSheet已经废弃了,用alertController替代。
主要用法如下:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"登录失败,请重新输入用户名和密码" message:message preferredStyle:UIAlertControllerStyleAlert];
// 按钮
UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
[self login];
}];
[self presentViewController:alertController animated:YES completion:nil];
如果是想要在弹出消息框中可以增加输入。
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"userName";
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"password";
[textField setSecureTextEntry:YES];
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
}];
但是注意,addTextFieldWithConfigurationHandler 该方法只能针对UIAlertControllerStyleAlert样式如果是UIAlertControllerStyleActionSheet样式,系统是崩溃的。
在pad设备上,如果想要使用UIAlertControllerStyleActionSheet样式的alertController,无法使用presentViewController弹出,需要使用UIPopoverController弹出。
而在phone设备上不支持UIPopoverController的。
- ios8下,alertController之初体验
- AlertController(iOS8)
- alertController
- AlertController
- Centos下Mysql之Mycat初体验
- iOS alertController之actionsheet样式添加控件(类似自定义actionsheet)
- XP 下Python / C++混合编程 之初体验
- AlertController解析
- 自定义AlertController
- Statspack之初体验
- Vista之初体验
- MySQL之初体验
- 工作之初体验
- java之初体验
- Mondrian之初体验
- Statspack之初体验
- LR之初体验
- SOA 之初体验
- FormsAuthentication.SetAuthCookie函数使用无效
- BZOJ 3668([Noi2014]起床困难综合症-2进制拆分)
- Matrix 手势运动
- poj 1273 Drainage Ditches
- ShellExecuteEx调用第三方程序
- ios8下,alertController之初体验
- 用POI导出excel时,较长的数字不想被自动变为科学计数法的解决方式
- android在线升级apk
- windows下拷贝文件到linux下
- android 使用百度云推送
- spring错误-在spring里面找不到org.springframework.cache.ehcache.EhCacheManagerFactoryBean
- 阿里无线前端招聘内容一览(2)
- 单击操作即将鼠标移动至某个对象
- OC之NSString