startMonitoringSignificantLocationChanges在iOS5中不起作用

时间:2013-04-03 08:23:15

标签: iphone ios objective-c

这就是我启动我的位置经理的方式:

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

在iOS6中,在创建它之后,使用我当前的位置调用委托:

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

但是,如果Im测试设备是iOS5,则永远不会调用此委托。

可能是什么原因?

1 个答案:

答案 0 :(得分:3)

问题在于方法

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

是iOS6的新功能,在iOS5中你必须使用:

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