在一个快速的应用程序中,我想在等待10秒后开始用相机录制视频。
等待10秒后,将调用此函数:
func startRecording() {
// trigger video recording
}
到目前为止,当用户点击“录制视频按钮”时,它会显示相机界面,然后用户必须点击内置录制按钮:
@IBAction func recordVideo(sender: AnyObject) {
if (UIImagePickerController.isSourceTypeAvailable(.Camera)) {
if UIImagePickerController.availableCaptureModesForCameraDevice(.Rear) != nil {
imagePicker.sourceType = .Camera
imagePicker.mediaTypes = [kUTTypeMovie as String]
imagePicker.allowsEditing = false
imagePicker.delegate = self
locationManager.startUpdatingLocation()
print(locationManager.location)
presentViewController(imagePicker, animated: true, completion: {})
} else {
postAlert("Rear camera doesn't exist", message: "Application cannot access the camera.")
}
} else {
postAlert("Camera inaccessible", message: "Application cannot access the camera.")
}
}
我正在尝试做的是,在“录制视频按钮”被击中10秒后自动触发录制。
我找不到有关如何“触发”录音的信息。 有没有办法做到这一点?
感谢您的帮助
答案 0 :(得分:2)
您可以在展示UIImagePickerController
:
imagePicker.performSelector(#selector(UIImagePickerController.startVideoCapture), withObject: nil, afterDelay: 10)