GPS应用停止在iOS 5上工作 - 位置管理器未更新 [英] GPS app stopped working on iOS 5 - Location Manager not updating

查看:109
本文介绍了GPS应用停止在iOS 5上工作 - 位置管理器未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个针对iOS 4.3的应用程序。它运行良好。但是,自从我迁移到iOS 5.0后,该应用程序开始显示出奇怪的行为。位置经理没有显示位置变化的更新。有没有人遇到这种问题?



感谢您的任何帮助。

解决方案


  1. 当我从iOS 4.x移动到5时,我与CLLocation经理分享了我的票价份额,

    你是否已经分类了CLLocationManager对象?


    • 问题
      在这种情况下,有时委托方法有时为
      不要调用(例如didUpdateLocation)。


    • 修正:不要CLLocationManager的子类

    • >

  2. CLLocationManager是从Singleton实例化的吗?

    • 问题:使用CLLocationManager对象作为单例对象的属性
      在4.x中正常工作,但在iOS5中不一致

    • 修复:将对象移至非单身人士对象

    • >如果上述任何一个都有帮助,或者您已经尝试过,并且它失败了

      • 问题:由于某些原因,CLLocationManager仍然不运行
        来自主线程,因此您会体验到奇怪的行为。
      • appDelegate
        中的一个属性,但不包含它的子类。 (这个解决方案证明是最好的,即使在越狱的iPhone手机上)
        。如果您的设计与案例2相似,您仍然可以使用指向其单例实例的动态属性。
      • 修复#2 :更肮脏的解决方案是确保它使用 performSelectorOnMainThread 或其他方式从主runloop运行


希望这有助于:)


I have developed an app targeted for iOS 4.3. It worked fine. But since I migrated to iOS 5.0, the app has started showing strange behavior. The location manager is not showing updates on change in position. Has anyone encountered this kind of problem?

Thanks for any help.

解决方案

I had my fare share with CLLocation manager weird updating issues when moving from iOS 4.x to 5:

  1. Have you subclassed the CLLocationManager object ?

    • problem : In that case sometime the delegate methods sometime don't get called (ex. didUpdateLocation).

    • fix: don't subclass CLLocationManager

  2. Is the CLLocationManager instanced from a Singleton ?
    • problem: using the CLLocationManager object as a property of a singleton object worked fine in 4.x but was inconsistent in iOS5
    • fix:move the object to a non-singleton object
  3. If either of the above helps , or you've tried it and it failed
    • problem: for some reason the CLLocationManager still doesn't run from the main thread and so you experience the strange behavior.
    • fix#1: create the CLLocationManager object as a property in the appDelegate without subclassing it . (this solution proved to work best , even on jailbroken iphones) . you can still use a dynamic property pointing to it's instance from the singleton if you design is similar to case 2.
    • fix#2: a more dirty solution is making sure it runs from the main runloop either using performSelectorOnMainThread or some other way

Hope this helps :)

这篇关于GPS应用停止在iOS 5上工作 - 位置管理器未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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