我相信这是非常基本的,但我一直无法找到任何有关它。设置代理
我有一个viewController女巫有一个模式segue到一个导航控制器与一堆表单工作表viewControllers。像这样:
的viewController A ---(模态赛格瑞)---> navigationController --->的viewController乙--->的viewControllerÇ
在CI的viewController取得委托,像这样:
@protocol ViewControllerCDelegate <NSObject>
- (void)myMehtod;
@end
@interface ViewControllerC : UIViewController
@property (nonatomic, assign) id <ViewControllerCDelegate> myDelegate;
(我已经合成myDelegate)
我想设置myDelegate是A.的viewController我的问题是,在这里?我该怎么办?
我试图以这一个的viewController的viewDidLoad中:
ViewControllerC *delegateController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerC"];
delegateController.myDelegate = self;
但委托不出现才能完成设置。想法?
你确定'delegateController'实际上正在被实例化吗?你是否坚持在某个地方的参考? – 2013-03-21 18:04:22
您确定您在上述代码段中引用的ViewControllerC实例是最终实际使用的吗?也就是说,你没有在别处实例化相同的视图控制器? – 2013-03-21 18:07:36
您应该在ViewControllerC出现时设置委托,而不是在ViewControllerA出现时进行设置。而且你不需要综合myDelegate。 – AMayes 2013-03-21 18:08:35