尝试写这个:
if usergavepermissiontousercamera opencamera else showmycustompermissionview
找不到执行此简单任务的当前方法。 注意:即使需要其他方法,iOS7也应该可以使用
您可以使用以下代码执行相同的操作:
if AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) == AVAuthorizationStatus.Authorized { // Already Authorized } else { AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { (granted: Bool) -> Void in if granted == true { // User granted } else { // User rejected } }) }
注意:
AVFoundation
import AVFoundation
SWIFT 3
if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == AVAuthorizationStatus.authorized { // Already Authorized } else { AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted: Bool) -> Void in if granted == true { // User granted } else { // User Rejected } }) }
if AVCaptureDevice.authorizationStatus(for: .video) == .authorized { //already authorized } else { AVCaptureDevice.requestAccess(for: .video, completionHandler: { (granted: Bool) in if granted { //access allowed } else { //access denied } }) }