小编Jas*_* P.的帖子

Swift 4 - 更新隐私设置 CLLocationManager 后刷新视图

我正在创建一个基于位置的应用程序,当用户拒绝位置访问时,会弹出一个警报视图,要求用户转到设置页面并更新设置以允许位置访问。如果用户允许访问然后按回,则视图不会使用允许更新位置的更新设置刷新。

是否有可以在用户从设置页面返回应用程序后运行的功能,该功能将刷新并开始更新位置。

我感谢任何建议或帮助。谢谢你。

用户看到警报: 警报图像

用户单击返回应用程序后,页面需要刷新以更新地图上的位置: 在此处输入图片说明

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, …
Run Code Online (Sandbox Code Playgroud)

cllocationmanager ios swift

3
推荐指数
1
解决办法
1370
查看次数

标签 统计

cllocationmanager ×1

ios ×1

swift ×1