我有一个带有四个选项卡栏项的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