1

アプリを閉じずに設定ページに移動することで、位置情報サービスのアラートを呼び出して再度ポップアップすることはできますか?一部のユーザーは、ポップアップが表示されたら「許可するか許可しないか」を選択する必要があるかどうかわかりません。問題の解決策.

4

2 に答える 2

4

ユーザーに位置情報サービスのステータスを通知する必要がある場合は、それに関する独自のアラートを提供し、ユーザーを [設定] ページに移動できます。

      - (void) showLocationAlert {

                if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) {

                        //Check whether Settings page is openable (iOS 5.1 not allows Settings page to be opened via openURL:)
                        if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]) {
                            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"You must enable location service,Turn on location service to allow \"YourApp\" to determine your location" delegate:self cancelButtonTitle:@"Settings" otherButtonTitles:@"Cancel", nil];
                            [alert show];

                        }
                        else {
                            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"You must enable location service" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
                            [alert show];
                        }
                 }
            }



  - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  {
          if (buttonIndex == 0) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
            }

        }
于 2012-09-13T05:12:43.263 に答える
0

残念ながら、デバイスが脱獄されていない限り、これを行うことはできません。ただし、ユーザーを設定ペインの正しい領域にルーティングするのは比較的簡単です。

于 2012-09-13T05:29:34.360 に答える