我手动将另外两个控制器(UINavigationControllerDelegate
& UIImagePickerController
)添加到UIViewController
,我在添加UIImagePickerController
后收到错误消息
Multiple inheritance from classes UIViewController and UIImagePickerController
我现在还不确定如何解释和解决这个问题。
由于此错误,我在使用image.delegate
方法并将其设置为self
Type ViewController does not conform to protocol UIImagePickerControllerDelegate
代码:
class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerController {
@IBAction func pickImage(sender: UIButton) {
var image = UIImagePickerController()
image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
image.allowsEditing = false
self.presentViewController(image, animated: true, completion: nil)
}
答案 0 :(得分:25)
您的第一行应该有UIImagePickerControllerDelegate,而不是UIPickerViewController。系统认为你试图让你的控制器继承UIViewController和UIImagePickerController这是不允许的。
答案 1 :(得分:1)