IOS 9错误域= kCLErrorDomain Code = 0"(null)" [英] IOS 9 Error Domain=kCLErrorDomain Code=0 "(null)"

查看:208
本文介绍了IOS 9错误域= kCLErrorDomain Code = 0"(null)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码应获取当前位置。但是会产生上述错误。函数didUpdateLocations永远不会被调用。

Code below should get current location. But above error is generated. Function didUpdateLocations never gets called.

在设备(iPhone 5s)iOS 9.1上运行此功能。 Info.plist具有所需的设备功能和隐私 - 配置位置使用说明,如附图所示。请帮忙!

Running this on a device (iPhone 5s)iOS 9.1. Info.plist has Required device capabilities and Privacy - Location usage description configured as shown in the attached image. Please help!

let locationManager = CLLocationManager()

override func viewDidLoad() {
    super.viewDidLoad()
    locationManager.delegate = self
    locationManager.requestAlwaysAuthorization()
    locationManager.requestLocation()
}


func locationManager(manager: CLLocationManager,
    didFailWithError error: NSError) 
    print(error.description)
}

func locationManager(manager: CLLocationManager, didUpdateLocations
      locations: [CLLocation]) {        
 print("got location")
}

推荐答案

请试试这个:

Go至:


  • 产品 - >方案 - >编辑方案 - >选项 - >允许位置模拟必须检查并尝试提供默认地点,不要将其设置为无

  • Product -> Scheme -> Edit Scheme -> Options -> Allow Location Simulation must be checked and try providing a default location, don't leave it set to "none"

编辑:如上所述在评论中,也重新启动Xcode,你就完成了!

EDIT : As mentionned in the comments, also restart Xcode and you're done !

希望这会有所帮助。

这篇关于IOS 9错误域= kCLErrorDomain Code = 0"(null)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆