2. Control-drag the button to ViewController.swift and selection 'Action' as the connection type. Name it captureVideo and obtain the code as below:
@IBAction func captureVideo(sender: AnyObject) {
}
3. Write the code as below:
import UIKit
import MobileCoreServices
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBAction func captureVideo(sender: AnyObject) {
if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) {
var myPickerController = UIImagePickerController()
myPickerController.delegate = self
myPickerController.allowsEditing = true
myPickerController.sourceType = UIImagePickerControllerSourceType.Camera
myPickerController.mediaTypes = [kUTTypeMovie]
self.presentViewController(myPickerController, animated: true, completion: nil)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
No comments:
Post a Comment