我有一個帶有四個選項卡欄項的TabBarApplication。當切換選項卡時,LocationManager仍然存在
我的第三個選項卡使用CLLocationManager來定位用戶的位置等等。
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
[locationManager stopUpdatingLocation];
NSLog(@"error%@",error);
switch([error code])
{
case kCLErrorNetwork:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your network connection or that you are not in airplane mode." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
break;
case kCLErrorDenied:{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"You have denied to allow Berns to get your location. " delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unknown network error." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
break;
}
}
但是當我切換標籤第四,這happends:
我得到的消息的UIAlertView中:
Unknown network error.
不與CLLocationManager死的時候切換選項卡? 我在dealloc方法中調用了[release] - 方法。
我不知道爲什麼會發生這種情況。但是自從我發佈這個帖子以來,它再也沒有發生過,所以它已經是別的了...... – 2010-09-21 15:29:46