[英]Cannot assign value of type 'Class<T>' to type 'protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>?'
I'm hoping someone has run into this before. 我希望有人遇到过这个问题。 I'm trying to assign this class to be the delegate for the UIImagePickerController and I'm getting this error:
我试图将此类分配为UIImagePickerController的委托,并且出现此错误:
"PictureViewController.swift:40:32: Cannot assign value of type 'PictureViewController' to type 'protocol?'" “ PictureViewController.swift:40:32:无法将类型为“ PictureViewController”的值分配为类型为“协议?””
Any ideas? 有任何想法吗? Thanks in advance.
提前致谢。
import UIKit
import MVCarouselCollectionView
import Eureka
import RealmSwift
public class PictureViewController<T: Equatable>: FormViewController, TypedRowControllerType,
MVCarouselCollectionViewDelegate, UIImagePickerControllerDelegate{
public var row: RowOf<T>!
public var completionCallback : ((UIViewController) -> ())?
let imagePicker = UIImagePickerController()
public override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.setRightBarButtonItem(
UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "loadImageButtonTapped:"), animated: true)
imagePicker.delegate = self <<<==== THIS GIVES ERROR MESSAGE
}
} }
Actually I figured it out. 其实我知道了。 I just had to also declare that this class implements the UINavigationControllerDelegate and all works now.
我只需要声明该类实现了UINavigationControllerDelegate,并且现在所有工作即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.