2013-04-03 21 views
3

工作這是我的init我的位置經理:startMonitoringSignificantLocationChanges不是在iOS5中

self.locationManager = [[[CLLocationManager alloc] init] autorelease]; 
    self.locationManager.delegate = self; 
    [self.locationManager startMonitoringSignificantLocationChanges]; 

在iOS6的,創建它之後,委託叫我目前的位置:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 

然而,如果設備Im測試是iOS5,則此代理從不會被調用。

可能是什麼原因?

+0

的代表應儘快稱爲startMonitoringSignificantLocationChanges,因爲它在說文檔,因爲它在iOS6中工作 –

回答

3

的問題是,該方法

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 

是一個新的iOS6的,在iOS5中你必須使用:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
+0

這就是問題,出色的人! –