CLLocationManager startUpdatingLocation在application:didFinishLaunchingWithOptions中不起作用:

时间:2014-11-15 10:45:12

标签: xcode ios6 cllocationmanager

我正在AppDelegate的方法应用程序中使用CLLocationManager startUpdatingLocation:didFinishLaunchingWithOptions: 委托方法永远不会被解雇。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...

    [self performSelectorOnMainThread:@selector(startUpdatingLocation) withObject:nil waitUntilDone:NO];

//    [self startUpdatingLocation];

    return YES;
}

-(void)startUpdatingLocation
{
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];
}

我已经尝试了两种方法,使用主线程并只调用我的方法,但它们都没有工作。

我已经实现了所有这些方法,但没有一个被触发:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

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

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

解决方案:

https://devforums.apple.com/message/1073496#1073496

0 个答案:

没有答案