jeudi 29 septembre 2016

Image picker that displays both camera and photo library in swift 3 [duplicate]

First off this was the video tutorial I was trying to follow https://www.youtube.com/watch?v=YYS-LwvluL8. I have just recenlty installed the new Xcode update. So I am working with swift 3.

All this video has is a image picker, a camera, and a load photo gallery. I was able to load a photo from my saved album but I was not able to use the camera feature. If I had used the camera feature it gave me a sigabrt error. I also can't access my photo gallery anymore either within the app. All I am looking for is a exact replica of what the youtube videos tutorial represents. I have also put my view control code below. Thanks.

  import UIKit

class ViewController: UIViewController,    UINavigationControllerDelegate,      UIImagePickerControllerDelegate{

 @IBOutlet weak var x: UIImageView!
 override func viewDidLoad() {
  super.viewDidLoad()
   }


  @IBAction func camera(_ sender: AnyObject) {

let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.camera
present(imagePicker, animated: true, completion: nil)
  }

 @IBAction func savedphotos(sender: AnyObject) {
 let imagePicker = UIImagePickerController()
 imagePicker.delegate = self
 imagePicker.sourceType =         UIImagePickerControllerSourceType.photoLibrary
present(imagePicker, animated: true, completion: nil)

}

Aucun commentaire:

Enregistrer un commentaire