【问题标题】:iphone: didUpdateLocations not invoked when testing with the simulatoriphone:使用模拟器进行测试时未调用 didUpdateLocations
【发布时间】:2015-11-21 14:39:03
【问题描述】:

在使用模拟器调试我的应用程序时,从不涉及例程 didUpdateLocations。我的工作:

在模拟器中,选择Debug>location>Custom Location,弹出经纬度窗口。按确定时,我希望调用 didUpdateLocations。

我在 ViewController 模块中使用 locMgr 作为全局变量:

locMgr = CLLocationManager()

并且在viewDidLoad-function中包含如下序列:

    locMgr.delegate = self
    if CLLocationManager.authorizationStatus() == .NotDetermined {
        locMgr.requestWhenInUseAuthorization()
    }

我已将 didUpdateLocations 函数编码为我的 viewcontroller 类的方法。我还验证了(调试器),在初始化期间调用了 requestWhenInUseAuthorization 例程。那么问题来了,为什么没有调用 didUpdateLocations 协议例程?

【问题讨论】:

  • 我发现,即使在调用 requestWhenInUseAuthorization() 之后,状态也没有改变,仍然是 .NotDetermined
  • 您是否按照here 的描述将这两个键添加到您的Info.plist 中?
  • 我没有在模拟器中运行我的应用程序,而是将它下载到我的 iPhone 上。相同的行为。未调用 didUpdateLocations。
  • 是的 - 丢失的是 Info.plist 文件条目。谢谢你对苹果的羞辱和羞辱。 Info.plist 中需要此条目的事实被很好地隐藏了......
  • 不幸的是,我无法将其发布为答案,因为它太琐碎了。

标签: ios-simulator ios9 cllocationmanager


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 2013-11-06
    • 2014-01-02
    • 2017-02-13
    • 1970-01-01
    • 2014-06-21
    • 2020-03-05
    相关资源
    最近更新 更多