一個更糟糕的一天上帝知道什麼,一旦我點擊刷新按鈕,這一點,但委託方法CLLocation Mangaer問題不叫,這個按鈕我的點擊問位置管理器更新位置信息iphone:CLLocation經理的委託方法不叫上一個按鈕,點擊
-(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];
} 請幫我解決這個問題。
在此先感謝
是啊,這是相當該死的沒用。爲什麼建議它,如果沒有必要這樣做? – 2011-05-27 11:04:49
我無法想象爲什麼應該重新開始更新,但也許有提供示例代碼背後的邏輯? :) – knuku 2011-05-27 11:35:21