美文网首页
权限判定和跳转设置

权限判定和跳转设置

作者: 夜空丶 | 来源:发表于2017-05-02 16:01 被阅读0次

    1.相机权限

    NSString *mediaType = AVMediaTypeVideo;//读取媒体类型

    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授权状态

    if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){

    NSLog(@"没有开启相机权限");

    }

    2.麦克风权限(注意这是异步的)

    [[AVAudioSession sharedInstance]requestRecordPermission:^(BOOL granted) {

    if (!granted)

    {

    NSLog(@"没有开启麦克风权限");

    }else{

    NSLog(@"已经开启麦克风权限");

    }

    3.跳转设置

    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

    iOS交流群:147881723

    相关文章

      网友评论

          本文标题:权限判定和跳转设置

          本文链接:https://www.haomeiwen.com/subject/pgnctxtx.html