我使用 Swift 3.0 和 Xcode 8 Beta 2 创建了一个 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>
难道我做错了什么?