ios 查询相册/摄像头/麦克风 的使用权限
2016-02-24 15:52
204 查看
www.MyException.Cn 网友分享于:2015-06-21 浏览:0次
iOS如何判断应用是否开启摄像头权限
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
AVAuthorizationStatusNotDetermined = 0, //点击允许访问时调用 //用户明确许可与否,媒体需要捕获,但用户尚未授予或拒绝许可。
AVAuthorizationStatusRestricted,
AVAuthorizationStatusDenied, //不允许
AVAuthorizationStatusAuthorized //允许访问
} NS_AVAILABLE_IOS(7_0);
麦克风权限检测:
//检测麦克风功能是否打开
[[AVAudioSessionsharedInstance]requestRecordPermission:^(BOOL granted) {
if (!granted)
{
[ViewUtilalertViewWithString:NSLocalizedString(@"麦克风功能未开启",nil)];
}
else
{
[selfrecord:sender];
}
}];
相册权限检测:需要
#import <AssetsLibrary/AssetsLibrary.h> //导入此类和AssetsLibrary.framework框架
int author = [ALAssetsLibrary authorizationStatus];
NSLog(@"author type:%d",author);
if(author == ALAuthorizationStatusRestricted || author == ALAuthorizationStatusDenied) {
// The user has explicitly denied permission for media capture.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"无法使用相册"
message:@"请在iPhone的\"设置-隐私-照片\"中允许访问照片。"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
[alert release];
return;
iOS如何判断应用是否开启摄像头权限
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
AVAuthorizationStatusNotDetermined = 0, //点击允许访问时调用 //用户明确许可与否,媒体需要捕获,但用户尚未授予或拒绝许可。
AVAuthorizationStatusRestricted,
AVAuthorizationStatusDenied, //不允许
AVAuthorizationStatusAuthorized //允许访问
} NS_AVAILABLE_IOS(7_0);
麦克风权限检测:
//检测麦克风功能是否打开
[[AVAudioSessionsharedInstance]requestRecordPermission:^(BOOL granted) {
if (!granted)
{
[ViewUtilalertViewWithString:NSLocalizedString(@"麦克风功能未开启",nil)];
}
else
{
[selfrecord:sender];
}
}];
相册权限检测:需要
#import <AssetsLibrary/AssetsLibrary.h> //导入此类和AssetsLibrary.framework框架
int author = [ALAssetsLibrary authorizationStatus];
NSLog(@"author type:%d",author);
if(author == ALAuthorizationStatusRestricted || author == ALAuthorizationStatusDenied) {
// The user has explicitly denied permission for media capture.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"无法使用相册"
message:@"请在iPhone的\"设置-隐私-照片\"中允许访问照片。"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
[alert release];
return;
相关文章推荐
- iOS 设计模式之外观模式 (Facade)
- iOS开发通知那些事
- 16年上传AppStore出现:Missing iOS Distribution signing
- iOS9开放的新API--Spotlight使用指南
- You don't have permission to access /nagios/ on this server
- iOS - 判断用户是否允许推送通知
- 适配ios设备集锦
- ios 系统地图
- iOS核心动画 Core Animation2-CABasicAnimation
- iOS 本地推送通知
- iOS核心动画之CoreAnimation
- iOS开发 自带二维码扫描(仅支持iOS7及以上系统)
- CocoaPods安装与使用(附如何在x-code中显示免去一直去terminal修改的繁琐)
- iOS项目的真机调试部分总结
- 依网友要求发个修改award bios的方法(刷CPU微码)
- 27.iOS内存警告处理(didReceiveMemoryWarning)
- ios逆向教程使用的工具
- iOS 设计模式之模版方法模式 (TemplateMethod)
- AssetsLibrary显示本地照片
- ios 防止按钮快速点击造成多次响应的避免方法