问题描述
对不起,我无法为标题制定一个简短的问题..
如果我是一个类的子类使用委托协议和属性,我的委托仍然需要实现超类的委托协议,还是我必须为子类定义一个新的委托协议?
In case i subclass a class with a delegate protocol and property, does my delegate still need to implement the delegate protocol of the superclass, or do i have to define a new one for the subclass?
在我的情况下,我的子类 UIImagePickerController
:
In my case I subclassed UIImagePickerController
:
[(UIImagePickerController *)self.myUIImagePickerControllerSubclassInstance setDelegate:self];
当我尝试将其委托设置为 self
,从某些视图控制器我收到以下警告:
When I try to set its delegate to self
, from some view controller I get the following warning:
推荐答案
您的代表需要遵守 UIImagePickerController
属性声明:
Your delegate needs to comply with UIImagePickerController
property declaration:
@property(非原子,赋值)id< UINavigationControllerDelegate,UIImagePickerControllerDelegate>委托
因此,尝试将< UIImagePickerControllerDelegate>
添加到您的子类接口:
So, try adding <UIImagePickerControllerDelegate>
to your subclass interface:
@interface YourPicker : UIImagePickerController <UIImagePickerControllerDelegate>
...
@end
可能你需要 UINavigationControllerDelegate
并实施强制方法(如果有的话)。
And probably you'll need UINavigationControllerDelegate
and implement mandatory methods, if any.
这篇关于子类化后委托?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!