5

ユーザーのALAssetsLibraryに最初にアクセスしようとすると、OSはユーザーに許可を求めるダイアログを表示します。これが許可されていない場合、failureBlockが呼び出され、今後も常に呼び出されます。この承認リクエストのプロンプトを再度強制する方法はありますか?

マップアプリで、ボタンで位置情報サービスをオンにするために設定アプリに移動するようにユーザーに通知していることに気付きました。ただし、プログラムで設定アプリを開く方法はありません。位置情報サービスをオンにする方法についての指示を表示するだけでよいですか?

4

2 に答える 2

6

Appleが承認した方法で設定アプリを開くことはできません。期待できる最善の方法は、エラーをトラップしてから、UIAlertViewまたはその他のビューを表示してこれを行う方法を説明することです。Dropboxアプリの最新版を見て、ユーザーにどのように指示するかについてのアイデアを確認してください。

于 2011-05-03T22:47:38.757 に答える
0

コードからライブラリにアクセスしようとすると、エラーハンドラーを使用してエラーをキャッチし、ユーザーに何をすべきかを指定するアラートを表示できます。

failureBlock:^(NSError *error) {
    // error handling
    if (error.code == ALAssetsLibraryAccessGloballyDeniedError) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" 
            message:@"Error loading image... \nEnable Location Services in 'Settings -> Location Services'." 
            delegate:self cancelButtonTitle:@"OK" 
            otherButtonTitles:nil, nil];
        [alert show];
    } else if (error.code == ALAssetsLibraryAccessUserDeniedError) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" 
            message:[NSString stringWithFormat:@"Error loading image... \nEnable Location Services in 'Settings -> Location Services' for %@.", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]] 
            delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"Error loading image..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }
}
于 2012-12-22T16:46:47.920 に答える