Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 开始监视重要位置更改在iOS5中不起作用_Iphone_Ios_Objective C - Fatal编程技术网

Iphone 开始监视重要位置更改在iOS5中不起作用

Iphone 开始监视重要位置更改在iOS5中不起作用,iphone,ios,objective-c,Iphone,Ios,Objective C,这是我初始化我的位置管理器的方式: self.locationManager = [[[CLLocationManager alloc] init] autorelease]; self.locationManager.delegate = self; [self.locationManager startMonitoringSignificantLocationChanges]; 在iOS6中,在创建委托后,立即使用我的当前位置调用委托: - (void)locati

这是我初始化我的位置管理器的方式:

    self.locationManager = [[[CLLocationManager alloc] init] autorelease];
    self.locationManager.delegate = self;
    [self.locationManager startMonitoringSignificantLocationChanges];
在iOS6中,在创建委托后,立即使用我的当前位置调用委托:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
但是,如果设备Im测试为iOS5,则永远不会调用此委托


原因可能是什么?

问题在于方法

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 
是iOS6的新功能,在iOS5中,您必须使用:

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

正如文档中所述,一旦StartMonitoringSignificantLocation发生更改,以及在iOS6中工作,就应该调用该委托