gpt4 book ai didi

ios - 显示位置权限对话框并立即消失

转载 作者:搜寻专家 更新时间:2023-10-30 22:31:49 25 4
gpt4 key购买 nike

iOS对话框提示半秒后消失:

        let locationManager = CLLocationManager()
switch CLLocationManager.authorizationStatus() {
case .authorizedWhenInUse:
print("In Use \(locationManager.location?.description)")
case .denied, .restricted:
print("denied")
case .notDetermined:
locationManager.requestWhenInUseAuthorization()
case .authorizedAlways:
print("always \(locationManager.location)")
}

我不知道这是否相关,但我正在使用 SWReavealViewController。Xcode9,为iOS 8.0编译,模拟器和真机均有

最佳答案

您的 locationManager 变量不会超出其定义范围(该代码片段所在的函数),因此在用户响应对话框之前它会被释放。

如果您将 let locationManager = CLLocationManager() 移至类变量,它应该保留。

关于ios - 显示位置权限对话框并立即消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46835674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com