0

4 つのタブ バー項目を持つ TabBarApplication があります。

3 番目のタブでは、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;
}

}

しかし、タブを 4 番目に切り替えると、次のことが起こります。

次のメッセージを含む UIAlertView を取得します。

Unknown network error.

タブを切り替えると CLLocationManager は死にませんか? dealloc-method で [release]-method を呼び出しました。

4

2 に答える 2

0
**use this in dealloc method**

-(void)dealloc
{

  [locationManager stopUpdatingLocation];

locationManager.delegate=nil;

[locationManager release];
}

//...........cheers.
于 2013-01-30T13:49:16.843 に答える
0

ネットワーク接続を確認するための Reachability を実装していなかったことが関係していると思います。

これは、App Store ガイドライン (またはいわゆる) の要求でもあります。

答えは次のとおりです。到達可能性を使用してインターネット接続を確認し、アプリケーションがこれを要求するかどうかをユーザーに通知します。

于 2010-09-28T10:38:35.063 に答える