0
+(void) vStartUpdatingLocation
{
    while (false);
    AssertNonMainThread
    [[NSOperationQueue mainQueue]addOperationWithBlock:^{
        CLLocationHandler * singleton = [CLLocationHandler singleton];
        CLLocationManager * locationManager = singleton.locationManager;
        NSAssert(locationManager.delegate==singleton,@"They are meant for each other"); //Assertion here
        [locationManager startUpdatingLocation]; //update location
        PO(singleton.locationManager);
        PO(singleton.locationManager.delegate);
        PO(singleton); //verify that locationManager.delegate == singleton
        while(false);
    }];
}
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
    AssertMainThread;//break point here never called
    PO(self.locationManager);
    PO(manager);
    while(false);
    [self finishUpdating];
    [self updateCurrentPlaceCache:newLocation];
}
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    [self finishUpdating]; //no love here too
}

私はコメントにほとんどの情報を入れました。

locationManager.delegate が実際にタイプ CLLocationHandler のシングルトン オブジェクトであることを確認しました

まだ

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

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

は呼び出されません。以前は機能していました。

4

1 に答える 1

0

performSelectorOnMainThread を使用してロケーション マネージャーをセットアップする必要があります。バックグラウンド スレッドでセットアップすると機能しません。おそらく、実行ループがバックグラウンド スレッドでアクティブになっていないためです。CLLocationmanager デリゲートが呼び出されないのはなぜですか?を参照してください。

于 2013-04-22T14:35:35.270 に答える