【发布时间】:2015-06-18 17:21:10
【问题描述】:
我正在从 Nib 创建自定义 UIView 子类 (shareView)。 我为 shareView 创建了一个自定义协议,如下所示:
@protocol sharePopupDelegate
@required
-(void)userPublishedContent;
-(void)userAbortedPublish;
@end
@interface shareView : UIView
{
id<sharePopupDelegate> delegate;
}
在我的 main.storyboard 中,我创建了一个自定义 UIViewController myViewController,其中包含一个名为“popup”的 shareView 视图实例。
所以现在我得到了
@property (weak, nonatomic) IBOutlet shareView *popup;
我现在想从我声明的 shareView 方法中委托 myViewController,所以我这样做了
self.popup.delegate = self;
在 myViewController 内部,但协议的方法并未在 myViewController 内部调用。
所以我正确地看到了 shareView 实例,但无法与其委托交互。
你能帮帮我吗?
提前致谢
【问题讨论】:
-
首先,不要这样做 id
委托;使其成为弱属性。请发布 shareView 在其委托上执行委托方法时的代码。我正在寻找这样的东西:[self.delegate userPublishedContent];
标签: ios objective-c delegates storyboard subclass