【问题标题】:CLLocationManager does not call back method in delegateCLLocationManager 不回调委托中的方法
【发布时间】:2013-12-21 23:11:41
【问题描述】:

CLLocationManager 不回调方法:

locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;

在用户许可后。

我在单例类(某种经理)中分配 CLLocationManager 实例,将委托分配给自己,一切看起来都很好,但没有工作。

我的应用程序中还有许多多线程逻辑,我认为问题是死锁或与多线程相关的其他问题。

我怎样才能揭示问题所在。

附:我也试过打电话

startMonitoringSignificantLocationChanges; 

在主线程上,这没有帮助。

【问题讨论】:

  • 授权后[CLLocationManager locationServicesEnabled]返回什么?
  • 我不会调用 startMonitoringSignificantLocationChanges,但我会调用 startUpdatingLocation,这很完美,委托方法被解雇了
  • @PatrickGoley "YES" 返回。但看起来 CLLocationManager 出于某种原因被冻结,因此没有调用回调。

标签: ios objective-c multithreading callback cllocationmanager


【解决方案1】:

好的,经过几个小时的尝试,我发现了这个: post.

解决办法是在主线程上分配CLLocationManager。

【讨论】:

    【解决方案2】:

    您对CLLocationManager 有强烈的引用吗?它应该是一个强大的属性@property CLLocationManager *myManager; 或类的实现中的 ivar(实例变量)。如果您在函数/方法中实例化CLLocationManager,并且没有分配任何引用,那么它将在您完成该函数后立即释放。

    对实例有强引用。

    【讨论】:

      【解决方案3】:

      一旦viewDidLoad 被调用,alloc/init CLocationManager 就为我工作。

      - (void)viewDidLoad {
          [super viewDidLoad];
      
          locationManager = [[CLLocationManager alloc] init];
      }
      

      【讨论】:

        猜你喜欢
        • 2011-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-03
        • 1970-01-01
        • 2011-11-18
        • 2016-05-12
        • 1970-01-01
        相关资源
        最近更新 更多