是否可以从widget / today扩展程序直接打开“设置”应用程序?
我已尝试过以下代码,但遗憾的是它无效
let url = URL(string:UIApplicationOpenSettingsURLString)!
extensionContext?.open(url) { _ in }
答案 0 :(得分:1)
此代码应该正常工作
guard let url = URL(string: UIApplicationOpenSettingsURLString) else {
return
}
extensionContext?.open(url, completionHandler: { (success) in
if !success {
var responder = self as UIResponder?
while (responder != nil){
let selectorOpenURL = NSSelectorFromString("openURL:")
if responder?.responds(to: selectorOpenURL) == true {
_ = responder?.perform(selectorOpenURL, with: url)
}
responder = responder?.next
}
}
})