1、判断用户是否获取了相册的访问权限
#import<AssetsLibrary/AssetsLibrary.h>
ALAuthorizationStatus author = [ALAssetsLibraryauthorizationStatus];
if(author == ALAuthorizationStatusRestricted || author ==ALAuthorizationStatusDenied){
//无权限
}
typedefenum{
ALAuthorizationStatusNotDetermined =0 // 用户尚未做出选择这个应用程序的问候
// User has not yet made a choice with regards to this application
ALAuthorizationStatusRestricted // 此应用程序没有被授权访问的照片数据。可能是家长控制权限
,// This application is not authorized to access photo data.
// The user cannot change this application’s status, possibly due to active restrictions
//such as parental controls being in place.
ALAuthorizationStatusDenied // 用户已经明确否认了这一照片数据的应用程序访问
// User has explicitly denied this application access to photos data.
ALAuthorizationStatusAuthorized //用户已经授权应用访问照片数据
// User has authorized this application to access photos data.
}
2.判断用户是否有权限访问相机
#import<AVFoundation/AVCaptureDevice.h>
#import<AVFoundation/AVMediaFormat.h>
AVAuthorizationStatus authStatus = [AVCaptureDeviceauthorizationStatusForMediaType:AVMediaTypeVideo];
if(authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied){
//无权限
}
3.判断是否开启定位服务
[CLLocationManagerlocationServicesEnabled]//检测的是整个的iOS系统的定位服务是否开启检测当前应用的定位服务是否开启需要通过一下方法来检测
- (void)locationManager:(CLLocationManager*)managerdidFailWithError:(NSError*)error
网友评论
添加图片到相册(写权限),需要用户授权,需要添加NSPhotoLibraryAddUsageDescription。