2011-11-18 11 views
0

停止CLLocationManagerのObjective-C

... .hファイル私は場所に一つだけの時間を更新する必要があるが、私はそれを文句を言わない仕事を更新するために停止しようとすると:

​​

。メートルのファイル:

@synthesize locMgr,delegate; 

    - (id)init { 
     self = [super init]; 

     if(self != nil) { 
      self.locMgr = [[[CLLocationManager alloc] init] autorelease]; // Create new instance of locMgr 
      self.locMgr.delegate = self; // Set the delegate as self. 
     } 

     return self; 
    } 

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
     if([self.delegate conformsToProtocol:@protocol(CoreLocationControllerDelegate)]) 
     { // Check if the class assigning itself as the delegate conforms to our protocol. If not, the message will go nowhere. Not good. 
      [self.delegate locationUpdate:newLocation]; 
      [self.locMgr stopUpdatingHeading]; 
      [self.locMgr setDelegate:nil]; 
     } 
    } 

    - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { 
     if([self.delegate conformsToProtocol:@protocol(CoreLocationControllerDelegate)]) { // Check if the class assigning itself as the delegate conforms to our protocol. If not, the message will go nowhere. Not good. 
      [self.delegate locationError:error]; 
     } 
    } 

私はクラスにしようと、私は私のViewControllerでそれを宣言するときに、どちらも文句を言わない動作するようです....

答えて

1

あなたは見出しではなく-stopUpdatingLocationを使ってみましたか?

関連する問題