비디오 카메라 코드 및 imagePicker 델리게이트를 사용한 Swift 4 답변 :
import MobileCoreServices
비디오 카메라 열기
@IBAction func openVideoCamera(_ sender: Any) {
if UIImagePickerController.isSourceTypeAvailable(.camera) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
imagePicker.mediaTypes = [kUTTypeMovie as String]
imagePicker.videoMaximumDuration = 10 // or whatever you want
imagePicker.videoQuality = .typeMedium
imagePicker.allowsEditing = false
present(imagePicker, animated: true, completion: nil)
}
ImagePicker 대리자 :
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let mediaType = info[UIImagePickerControllerMediaType] as AnyObject
if mediaType as! String == kUTTypeMovie as String {
let videoURL = info[UIImagePickerControllerMediaURL] as? URL
print("VIDEO URL: \(videoURL!)")
}
dismiss(animated: true, completion: nil)
}
@import MobileCoreServices;