[英]Connect subclass's custom delegate for control in Interface Builder
I've got a custom control with a custom delegate: 我有一个自定义控件与自定义委托:
@class MyButtonSubclass;
@protocol MyButtonSubclass Delegate <NSObject>
@optional
- (void)delegateMethod:(NSString *)param;
@end
@interface MyButtonSubclass : UIButton
@property (nonatomic, weak) id < MyButtonSubclass Delegate> delegate;
@property (nonatomic, strong) NSString* param;
@end
And I've created a button in a Storyboard with the custom subclass: 我在自定义子类的Storyboard中创建了一个按钮:
Is there a way to get the custom delegate to appear in the list of connectable properties in the Storyboard? 有没有办法让自定义委托出现在Storyboard的可连接属性列表中?
Huzzah! 好哇! The answer was quite simply staring me in the face.
答案很简单地盯着我。 The
delegate
(or dataSource
) definitions need to include IBOutlet
: delegate
(或dataSource
)定义需要包含IBOutlet
:
@class MyButtonSubclass;
@protocol MyButtonSubclass Delegate <NSObject>
@optional
- (void)delegateMethod:(NSString *)param;
@end
@interface MyButtonSubclass : UIButton
@property (nonatomic, weak) IBOutlet id < MyButtonSubclass Delegate> delegate;
// ^ This!
@property (nonatomic, strong) NSString* param;
@end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.