首先,这是我试图关注的视频教程https://www.youtube.com/watch?v=YYS-LwvluL8。我刚刚重新安装了新的Xcode更新。所以我正在使用swift 3。
所有这些视频都有图像选择器,相机和加载照片库。我能够从我保存的相册中加载照片,但我无法使用相机功能。如果我使用了相机功能,它会给我一个sigabrt错误。我也无法在应用内访问我的照片库。我正在寻找的只是youtube视频教程所代表的精确复制品。我还把我的视图控制代码放在下面。感谢。
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)
}