【发布时间】:2011-05-27 10:52:07
【问题描述】:
再糟糕的一天,上帝知道这是什么问题,但是一旦我单击刷新按钮,就不会调用 CLLocation Mangaer 的委托方法,单击此按钮时我要求位置管理器更新位置
-(void) viewWillAppear:(BOOL)animated{
locationManager=[[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
NSLog(@"failed");
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
NSLog(@"current lat= %f and long=%f ", newLocation.coordinate.latitude, newLocation.coordinate.longitude);
NSDate *eventDate = newLocation.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 10) {
[lat setText:[ NSString stringWithFormat:@"%f", newLocation.coordinate.latitude]];
[lon setText:[ NSString stringWithFormat:@"%f", newLocation.coordinate.longitude]];
}
else {
[lat setText:@"Not changed"];
[lon setText:@"Not changed"];
}
}
-(IBAction) refrechLoc{
NSLog(@"updating location");
[locationManager startUpdatingLocation];
} 请帮我解决这个问题。
提前致谢
【问题讨论】:
标签: iphone cocoa-touch cllocationmanager