私はカメラロールにアクセスするアプリを実装しようとしています。私もSettings.bundleそれを追加iOS:iPhone設定をPHPhotoLibrary権限にリンクする方法
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
if (status != PHAuthorizationStatusAuthorized) {
NSString *accessDescription = [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"NSPhotoLibraryUsageDescription"];
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:accessDescription
message:@"To give permissions tap on 'Change Settings' button"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
[alertController addAction:cancelAction];
UIAlertAction *settingsAction = [UIAlertAction
actionWithTitle:@"Change Settings"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
options:@{}
completionHandler:nil];
}];
[alertController addAction:settingsAction];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController
animated:YES
completion:nil];
}
}
:ここで私は権限をチェックしています方法です
しかし、私はにトグルスイッチをリンクすることができますどのようにそれを把握していませんパーミッション。どのようにトグルスイッチをカメラのロール権限にリンクすることができますか?
私は本当にあなたの助けに感謝します。
を。 iOSはあなたが写真ライブラリにアクセスしたときにそれを行います。例えばhttp://stackoverflow.com/questions/13572220/ask-permission-to-access-camera-roll – Paulw11
@ Paulw11、同じページhttp://stackoverflow.com/questions/13572220/ask-permission-to-access -camera-roll/38398067#38398067ユーザーに設定を送信しています – user2924482
はい、設定が開きますが、自分のスイッチを置くことはできません。あなたが許可を求めたら、iOSはこれを行います。あなたがリンクしたコードでは、ユーザーが拒否した場合にユーザーに許可を要求することができます(iOSはユーザーに一度しか尋ねません。その後、設定したアクセス許可を使用します) – Paulw11