2013-12-21 71 views
2

CLLocationManager不會回撥方法:CLLocationManager不會再打委託方法

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

用戶的權限之後。

我在singleton類(管理器的種類)中分配CLLocationManager實例,將委託分配給self,所有的都看起來很好,但不起作用。

此外,我的應用程序中有很多多線程邏輯,我認爲問題是死鎖或與多線程相關的其他問題。

我該如何揭示出什麼問題。

P.S.我也嘗試致電

startMonitoringSignificantLocationChanges; 

在主線程上,這並沒有幫助。

+0

授權後,[CLLocationManager locationServicesEnabled]返回什麼? –

+0

我不會打電話給startMonitoringSignificantLocationChanges,但我打電話給startUpdatingLocation,這個工作很完美,委託方法被解僱了 – iiFreeman

+0

@PatrickGoley返回「YES」。但它看起來CLLocationManager由於某種原因被凍結,因此不會調用回調函數。 – Nikita

回答

1

好吧,經過幾小時的嘗試,我發現這個: post

解決方案是在主線程上分配CLLocationManager。

0

您是否強烈參考CLLocationManager?它應該是一個強大的屬性@property CLLocationManager *myManager;或在你的類的實現中的ivar(實例變量)。如果你正在函數/方法中實例化CLLocationManager,並且沒有給出任何引用,它將在你完成該函數後立即釋放。

對該實例有強烈的參考。

0

alloc/init CLocationManager儘快viewDidLoad被調用爲我工作。

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    locationManager = [[CLLocationManager alloc] init]; 
} 
相關問題