如何检查我的应用是否可以访问电话库 [英] How may I check if my app has access to phone gallery
本文介绍了如何检查我的应用是否可以访问电话库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,我用相机拍照并将该图像存储到本机库中。但如果应用程序没有权限,我希望用户知道这一点。那么如何查看呢?
I have an app in which I take a picture with the camera and store that image into the native gallery. But if the app doesn't have permission for that, I want the user to know that. So how do I check it?
顺便说一下:我将图像存储到图库中:
By the way: I store the image into the gallery with:
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
推荐答案
您需要检查<$ c $的状态c> ALAssetLibrary
确保您的文件中包含 AssetsLibrary / AssetsLibrary.h
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
//检查 ALAuthorizationStatusAuthorized
的状态或 ALAuthorizationStatusDenied
例如
// check the status for ALAuthorizationStatusAuthorized
or ALAuthorizationStatusDenied
e.g
if (status != ALAuthorizationStatusAuthorized) {
//show alert for asking the user to give permission
}
这篇关于如何检查我的应用是否可以访问电话库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文