카메라 롤에 액세스하는 앱을 구현하려고합니다. 여기 권한을 검사하고있어 방법 :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];
}
}
을 나는 또한 Settings.bundle 추가 :
하지만이에 토글 스위치를 연결할 수있는 방법을 알아낼 수있다 사용 권한. 토글 스위치를 카메라 롤 권한에 연결하려면 어떻게해야합니까?
정말 감사드립니다.
당신은이 코드를 시도 할 수 있습니다
을; 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