本文介绍了从警报启动设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从如下所示的警报中启动设置应用程序:

I wanted to launch settings app from an alert like you see below:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{NSString * title = [alertView buttonTitleAtIndex:buttonIndex];

{ NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

if([title isEqualToString:@"Ok"])
{
    NSLog(@"Ok was selected.");
}
else if([title isEqualToString:@"Safari"])
{
    NSLog(@"open Safari was selected.");
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];
}

}

我使用了prefs:root = General,但是随后我从下面的链接中阅读...

I used prefs:root=General, but then I read from the link below...

iOS启动设置->限制网址方案

...这在ios5.1中是不可能的.实际上,它在模拟器中不起作用.我能做什么??感谢您的帮助

...that this is not possible in ios5.1. Infact it does not work in the simulator. what can I do?? Thanks for the help

推荐答案

尝试一下(适用于iOS 5及更高版本):

Try this (works on iOS 5 and up):

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

这篇关于从警报启动设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 23:34