2017-09-26 101 views
5

似乎Apple已經將很多應用程序配置移至iOS 11的應用程序路徑,如何在設置中以編程方式打開應用程序路徑?我試過"App-Prefs:root=\(Bundle.main.bundleIdentifier!)",但這似乎不起作用。如何在設置中打開您的應用程序iOS 11

請注意,我的問題是具體到:如何打開設置應用程序路徑:如何打開設置

回答

10

這裏是你要尋找的代碼,我想:

if let url = URL(string:UIApplicationOpenSettingsURLString) { 
    if UIApplication.shared.canOpenURL(url) { 
     UIApplication.shared.open(url, options: [:], completionHandler: nil) 
    } 
} 
0

openURL,因爲iOS的10已被棄用,所以我會建議你使用:

if let url = URL(string:UIApplicationOpenSettingsURLString) { 
    if UIApplication.shared.canOpenURL(url) { 
     UIApplication.shared.open(url, options: [:], completionHandler: { success in 
      log.debug("Open app settings success: \(success)") 
     }) 
    } 
} 
相關問題