App设置UIAlertController
来源:互联网 发布:mac好玩的小游戏 编辑:程序博客网 时间:2024/06/03 17:47
转自:http://www.jianshu.com/p/727bd135c6f2
App中遇到需要用户打开设置界面的需求时,可以友好的引导用户去设置界面设置,而不是只是添加个提示,让用户自己去设置(可能他们也不知道怎么设置)
这样提示用户是不是很友好呢,那如何实现呢
UIAlertController * controller = [UIAlertController alertControllerWithTitle:@"提示" message:@"123456" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"Settiogs" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL * appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:appSettings];
}];
[controller addAction:action];
[self presentViewController:controller animated:YES completion:nil];
我开始在Appdelegate是这样写的(TextViewController * vc = [[TextViewController alloc]init];self.window.rootViewController = vc;(这个controller是根controller上发现界面不显示 出现这个错误Attempt to presentonwhose view is not in the window hierarchy!)当我变成这样写时
TextViewController * vc = [[TextViewController alloc]init];
UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = nav; 就ok了
非常重要的代码是NSURL * appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:appSettings];
}];
可以打开设置
- App设置UIAlertController
- UIAlertController设置
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIalertController
- UIAlertController
- UIalertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- 你的服务器没有正确响应Token验证的解决方法
- 获取视频的缩略图工具类
- php -CURL使用步骤
- htm5中的keygen的应用场景
- 将opengl的绘制效果利用OpenCV、Matlab保存成图片
- App设置UIAlertController
- iOS10适配—注册推送错误:Code=3000
- 原生js获取当前li元素的索引及demo
- C++开源程序库评话
- JAVA如何把一个float四舍五入到小数点后2位,4位,或者其它指定位数
- 如何用css 绘制边长相等且有边框的六边形
- 自定义控件让TextView的drawableLeft与文本一起居中显示
- C#中 ()=>的含义
- Entity Framework 5.0系列之Code First数据库迁移