Open Settings.app When Button is Tapped in UIAlertView on iPhone SDK [duplicate]

来源:互联网 发布:域名注册可靠吗 编辑:程序博客网 时间:2024/06/05 02:29

There is no way to do this.

Because till now (11th Jan 2013) there is no url scheme available for settings app.

So you can't do it on ios6

on ios5 (< 5.1): Call the official *Settings* app from my app on iPhone

ios7无法实现自定制弹出筐体点击按钮后进入settings页面。但是ios8开始就提供了这个支持了

图片描述

这是IOS8之后的一个新特性:即可以直接在应用内,跳转到应用的setting设置中,然后进行相应的操作!

eg:判断是否开启定位服务而言,如果没开启,则弹出alertview,跳转到设置中,代码如下:

if([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0){            UIAlertView *tipMessage = [[UIAlertView alloc] initWithTitle:@"定位服务已关闭" message:kCLMessage_AppDenied delegate:self cancelButtonTitle:nil otherButtonTitles:@"知道了", nil];            tipMessage.tag = 1001;            [tipMessage show];        }else{            UIAlertView *tipSettingMessage=[[UIAlertView alloc] initWithTitle:@"定位服务已关闭" message:kCLMessage_AppDenied delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil];            tipSettingMessage.tag=1002;            [tipSettingMessage show];        }
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  {    if (alertView.tag == 1002 && buttonIndex == 1){        //code for opening settings app in iOS 8        [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];    }}


0 0
原创粉丝点击