xcode 从警报启动设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9470125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:28:02  来源:igfitidea点击:

launch settings from alert

iosxcode

提问by Alessandro

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"]];
}

}

}

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

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

iOS Launching Settings -> Restrictions URL Scheme

iOS 启动设置 -> 限制 URL 方案

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

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

采纳答案by LJ Wilson

Try this (works on iOS 5 and up):

试试这个(适用于 iOS 5 及更高版本):

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

回答by Mani

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Assistant "]];

List of currently known URLs in the Settings app:

设置应用程序中当前已知的 URL 列表:

prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth
prefs:root=General&path=DATE_AND_TIME
prefs:root=FACETIME
prefs:root=General
prefs:root=General&path=Keyboard
prefs:root=CASTLE
prefs:root=CASTLE&path=STORAGE_AND_BACKUP
prefs:root=General&path=INTERNATIONAL
prefs:root=LOCATION_SERVICES
prefs:root=ACCOUNT_SETTINGS
prefs:root=MUSIC
prefs:root=MUSIC&path=EQ
prefs:root=MUSIC&path=VolumeLimit
prefs:root=General&path=Network
prefs:root=NIKE_PLUS_IPOD
prefs:root=NOTES
prefs:root=NOTIFICATIONS_ID
prefs:root=Phone
prefs:root=Photos
prefs:root=General&path=ManagedConfigurationList
prefs:root=General&path=Reset
prefs:root=Sounds&path=Ringtone
prefs:root=Safari
prefs:root=General&path=Assistant
prefs:root=Sounds
prefs:root=General&path=SOFTWARE_UPDATE_LINK
prefs:root=STORE
prefs:root=TWITTER
prefs:root=General&path=USAGE
prefs:root=VIDEO
prefs:root=General&path=Network/VPN
prefs:root=Wallpaper
prefs:root=WIFI
prefs:root=INTERNET_TETHERING