我正在尝试录制视频,然后保存在IOS设备上,我能够录制它,但我想知道如何保存在设备上?
import UIKit
import AVKit
import MobileCoreServices
class ViewController: UIViewController , UIImagePickerControllerDelegate , UINavigationControllerDelegate {
@IBOutlet weak var RecordButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func RecordAction(_ sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
print("Camera Available")
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
imagePicker.mediaTypes = [kUTTypeMovie as String]
imagePicker.allowsEditing = false
self.present(imagePicker, animated: true, completion: nil)
} else {
print("Camera UnAvaialable")
}
}
}
2条答案
按热度按时间h22fl7wq1#
首先确保将下面的Privacies添加到info.plist:
并在ViewDidLoad下添加以下函数
wgmfuz8q2#
我只是发布了一个更新和更详细的版本@HHH答案...使用
Xcode 14.3.1
和swift5