【发布时间】:2016-10-08 03:00:11
【问题描述】:
这是我的代码,一个简单的类,在故事板中创建了一个视图,其中包含一个用于呈现 imagePickerView 的按钮。 imagePickerView 被呈现,然后应用程序崩溃并显示libc++abi.dylib: terminating with uncaught exception of type NSException
import Foundation
import UIKit
class ImageSelectionView: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
override func viewDidLoad(){
super.viewDidLoad()
}
@IBAction func backButtonTapped(_ sender: AnyObject) {
self.navigationController?.dismiss(animated: true, completion: nil)
}
@IBAction func openPhotoLibrary(_ sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary;
imagePicker.allowsEditing = true
present(imagePicker, animated: true, completion: nil)
self.present(imagePicker, animated: true, completion: nil)
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
self.dismiss(animated: true, completion: nil);
}
}
不知道哪里出了问题,任何帮助都会很棒,谢谢!
【问题讨论】:
-
您是否要求获得照片的许可?
-
@MikeG 试试我的答案,让我知道它是否有效?
-
检查我的答案。
标签: ios swift nsexception photolibrary