我使用Swift3.0和Xcode8Beta2创建了一个iOS单视图应用程序。我正在连接AVFoundation.framework。
这是我的视图控制器代码:
import UIKit
import AVFoundation
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == .notDetermined {
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted: Bool) in
if granted {
print("granted")
}
else {
print("not granted")
}
})
}
}
}当我在我的设备上运行时,应用程序在执行AVCapture.requestAccess行后崩溃(完成处理程序不会执行,也不会抛出任何异常)。
控制台中唯一的内容是:
2016-07-15 14:55:44.621819 testpp[2261:912051] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-07-15 14:55:44.626012 testpp[2261:912051] [MC] Reading from public effective user settings.
2016-07-15 14:55:59.284610 testpp[2261:912085] [access] <private>我做错了什么吗?
发布于 2016-07-17 00:28:27
在请求摄影机访问权限时,请确保在Info.plist文件中设置了Privacy - Camera Usage Description密钥的值。
发布于 2016-07-25 08:56:39

输入info.plist所需的权限
https://stackoverflow.com/questions/38403387
复制相似问题