gpt4 book ai didi

iOS:如何将 iPhone 设置链接到 PHPhotoLibrary 权限

转载 作者:行者123 更新时间:2023-11-29 00:22:14 30 4
gpt4 key购买 nike

我正在尝试实现一个访问相机胶卷的应用程序。以下是我检查权限的方式:

-(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:

enter image description here

但我还没有弄清楚如何将切换开关链接到权限。你们中有人知道如何将切换开关链接到相机胶卷权限吗?

非常感谢您的帮助。

最佳答案

您可以尝试以下代码:

if (status == PHAuthorizationStatusNotDetermined) {
// Access has not been determined.
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusAuthorized) {
// do something
}else {
// Access has been denied.
}
}];
}

关于iOS:如何将 iPhone 设置链接到 PHPhotoLibrary 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44013350/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com