CLLocationManager没有调用委托方法 - 在主线程中设置CLLocationManager

时间:2012-06-24 20:50:29

标签: ios5 cllocationmanager clgeocoder

我有以下功能,我相信正在主线程中运行(这是分配按钮点击的事件)

-(void)startTracking:(CLLocation*) targetLocation
{
    NSLog(@"Target location: %@", targetLocation);
    self.locationManager = [[CLLocationManager alloc]init];
    [self.locationManager setDelegate:self];
    self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    self.targetRegion = [[CLRegion alloc] initCircularRegionWithCenter:targetLocation.coordinate radius:10 identifier:@"Destination Region"];

    [self.locationManager startMonitoringForRegion:self.targetRegion];
    //[self.locationManager startUpdatingLocation];
    NSLog(@"Target region: %@", self.targetRegion);
 }

我说“我认为”的唯一原因是,在此之前可以运行,我在另一个线程的块中运行targetRegion详细信息。

[geocoder geocodeAddressString:self.address completionHandler:^(NSArray* placemarks, NSError* error){
        for (CLPlacemark* aPlacemark in placemarks)
        {                    // Process the placemark.
            NSLog(@"Got Placemark : %@", aPlacemark);
            //newDestination.destination = aPlacemark.location;
        }
        //self.Destination.destination = [[placemarks objectAtIndex:0] location];
        self.targetLocation = [[placemarks objectAtIndex:0] location];
        self.startTrackingButton.enabled = true;
        self.stopTrackingButton.enabled = true;
    }];

这就是为什么代表没有被调用的原因......?

0 个答案:

没有答案