【发布时间】:2018-11-10 16:27:46
【问题描述】:
我正在创建一个基于位置的应用程序,当用户拒绝位置访问时,会弹出一个警报视图,要求用户转到设置页面并更新设置以允许位置访问。如果用户允许访问然后按回,则视图不会使用允许更新位置的更新设置刷新。
用户从设置页面返回应用程序后,是否可以运行刷新并开始更新位置的功能。
感谢任何建议或帮助。谢谢。
func alertForNoLocationAccess(){
let alert = UIAlertController(title: "Allow Location Access", message: "Cannot add location data and map coordinates to your entries without access. Press settings to update or cancel to deny access.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Settings", style: .default, handler: { action in
if let url = URL(string:UIApplication.openSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(alert, animated: true)
}
【问题讨论】:
标签: ios swift cllocationmanager