相关疑难解决方法(0)

在iOS 8中显示相机权限对话框

当我的应用程序第一次尝试在iOS 8上访问摄像头时,会向用户显示摄像头权限对话框,非常类似于iOS 7中用于麦克风访问的麦克风.

在iOS 7中,可以事先调用麦克风权限对话框,并查看是否已授予权限(例如,请参阅此问题).是否有类似的方法来调用iOS 8中的相机权限对话框?可以将对话组合用于麦克风和摄像机访问权限吗?

permissions camera ios ios8 ios-permissions

70
推荐指数
6
解决办法
7万
查看次数

如果用户拒绝摄像头访问,则无法显示警报

如果用户拒绝相机访问,我将显示一个带有取消和设置按钮的警报以显示它。但代码不起作用。

@IBAction func ProfileImageButton(_ sender: UIButton) {
        print("profile image Button is pressed")
        let imagePickerController = UIImagePickerController()
        imagePickerController.delegate = self
        profileimgbool = true
        let actionSheet = UIAlertController(title: "Photo Source", message: "choose a Source", preferredStyle: .actionSheet)

        actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .camera
            self.present(imagePickerController, animated: true, completion: nil)

        }))

        actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary
            self.present(imagePickerController, animated: true, completion: nil)}))

        actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))



        self.present(actionSheet, animated: true, completion: nil)

    }

 func checkCameraPermission() …
Run Code Online (Sandbox Code Playgroud)

iphone xcode alert objective-c ios

1
推荐指数
1
解决办法
5170
查看次数

标签 统计

ios ×2

alert ×1

camera ×1

ios-permissions ×1

ios8 ×1

iphone ×1

objective-c ×1

permissions ×1

xcode ×1