gpt4 book ai didi

ios - 手动要求用户访问照片或相机

转载 作者:行者123 更新时间:2023-11-29 12:22:09 24 4
gpt4 key购买 nike

我想知道如何在按下按钮时在屏幕上显示“此应用想要访问您的照片/相机:不允许,允许”。我有代码来检查是否启用了照片或相机,但没有显示允许或不允许的操作的代码。如何为每个(照片和相机)执行此操作?

最佳答案

在 Objective-C 中

-(void)showImagePicker
{
if ([AVCaptureDevice respondsToSelector:@selector(requestAccessForMediaType: completionHandler:)]) {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
dispatch_async(dispatch_get_main_queue(), ^{
if (granted) {
// Here you can implement your functions.
} else {
// This condition executes when the user taps Don't Allow option on the alertVeiw. This alert is an one time alert. so you may need to reset the privacy and location settings in your device settings.
[self cancel];
}
});
}];
} else {
[self cancel];
}
}

关于ios - 手动要求用户访问照片或相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30293099/

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