好吧,我知道关于它有很多问题,但它们都是很久以前的事了。

所以。我知道这是可能的,因为地图应用程序做到了。

在地图应用程序中,如果我关闭这个应用程序的本地化,它会给我发送一条消息,如果我按ok,“设置应用程序”就会打开。 我的问题是,这怎么可能呢? 如何从我自己的应用程序打开“设置应用程序”?

基本上我需要做同样的事情,如果用户关闭了我的应用程序的位置,那么我就会给他显示一条信息,上面写着将打开“设置应用程序”


当前回答

在Swift 3 / iOS 10+中看起来是这样的

if let url = URL(string: "App-Prefs:root=LOCATION_SERVICES") {
    UIApplication.shared.open(url, completionHandler: .none)
}

其他回答

你可以在iOS 5.0及更高版本上使用这个:这个不再有效。

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

添加到接受的答案:(来自苹果开发者文档)当你打开这个字符串(openSettingsURLString)构建的URL时,系统启动设置应用程序,并显示应用程序的自定义设置(如果有的话)。如果你想打开应用的设置,创建你自己的settings。bundle。

来自@Yatheeshaless的回答:

你可以在iOS8中以编程方式打开设置应用程序,但在早期版本的iOS中不能。

迅速:

   UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

斯威夫特4:

if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
    UIApplication.shared.openURL(url)
}

Swift 4.2 (BETA):

if let url = NSURL(string: UIApplication.openSettingsURLString) as URL? {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

objective - c:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

在Swift 3 / iOS 10+中看起来是这样的

if let url = URL(string: "App-Prefs:root=LOCATION_SERVICES") {
    UIApplication.shared.open(url, completionHandler: .none)
}

在iOS 10上测试。工作

NSArray* urlStrings = @[@"prefs:root=WIFI", @"App-Prefs:root=WIFI"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
    break;
}
}

快乐编码:)