0

私はiPhoneアプリケーションを開発しています。私が直面している問題は、アプリの開始時に、ユーザーが位置情報サービスを有効または無効にしたことに基づいて、2 つの異なるビューを表示する必要があることですが、数秒後に位置情報サービスのアラートが表示されます。どうすれば管理できますか? 流れはこうあるべき

アプリの起動 -> ロケーション アラートが表示されます - > ユーザーが許可を押す -> 取引ビューを表示します

アプリの起動 -> 場所のアラートが表示されます -> ユーザーが許可していません -> 選択した場所のビューが表示されます。

4

2 に答える 2

0

appDelegate で CLLocationManager を使用して、起動時にのみ表示される場所のアラートを取得することが役立つ場合があります。

于 2012-04-10T06:18:18.037 に答える
0

デリゲートで CLLocationManager を使用して場所を取得します。失敗した場合は、エラー コードをチェックして、ユーザーがアプリで位置情報へのアクセスを拒否していないかどうかを確認します。

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {

    UIAlertView *alert;
    //denied?
    if(error.code == kCLErrorDenied) alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error",@"Error title header") message:NSLocalizedString(@"Turn on Location Services in Settings to use your location",@"Turn on Location Services in Settings to use your location") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    else alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error",@"Error title header") message:NSLocalizedString(@"At the moment it is not possible to retreive your location",@"At the moment it is not possible to retreive your location") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
}
于 2012-04-10T08:24:51.833 に答える