iOS 判断相册 相机 位置权限
2016-02-16 本文已影响597人
小杂鱼
- 判断设备是否允许访问相机
"#import <AVFoundation/AVCaptureDevice.h>"
"#import <AVFoundation/AVMediaFormat.h>"
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
{
//请设置允许相机
}
设备是否开启定位
http://blog.csdn.net/mideveloper/article/details/46444195
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (kCLAuthorizationStatusDenied == status || kCLAuthorizationStatusRestricted == status) {
//请设置允许获取定位
}
- 判断用户是否有权限访问相册
"#import <AssetsLibrary/AssetsLibrary.h>"
ALAuthorizationStatus author = [ALAssetsLibraryauthorizationStatus];
if (author == kCLAuthorizationStatusRestricted || author ==kCLAuthorizationStatusDenied){
//无权限
}
typedef enum {
kCLAuthorizationStatusNotDetermined = 0, // 用户尚未做出选择这个应用程序的问候
kCLAuthorizationStatusRestricted, // 此应用程序没有被授权访问的照片数据。可能是家长控制权限
kCLAuthorizationStatusDenied, // 用户已经明确否认了这一照片数据的应用程序访问
kCLAuthorizationStatusAuthorized // 用户已经授权应用访问照片数据} CLAuthorizationStatus;
}