我有一个容器视图控制器说ContainerViewController和另一个UIViewController(PhotoViewcController)我将其添加为ContainerViewController中的childviewcontroller。 这条消息从ContainerViewController转发到PhotoViewcController。 但是,如何在父子视图控制器中使用双向关系? 以便将消息从PhotoViewcController传递到ContainerViewController。
I have a container view controller say ContainerViewController and another UIViewController(PhotoViewcController) which i am adding as a childviewcontroller in ContainerViewController. So that message is forwarded from ContainerViewController to PhotoViewcController. But how can i use the two way relation in the parent child view controllers? so that message is passed form PhotoViewcController to ContainerViewController.
最满意答案
像这样在子类中创建一个属性
@property (assign) id pDelegate;并合成它,当你转到子视图控制器时,在push / present之前将委托设置为self
childController.pDelegate = self;现在,当您要发送消息时,请执行此操作
if([self.pDelegate respndsToSelector:@selector(popedBackFromChild:)]) { [self.pDelegate popedBackFromChild:<some object>]; }告诉我你是否需要进一步解释
make a property in child class like this
@property (assign) id pDelegate;and synthesize it, and when you go to child view controller, set the delegate as self before push/present as
childController.pDelegate = self;now when you want to send the message, do this
if([self.pDelegate respndsToSelector:@selector(popedBackFromChild:)]) { [self.pDelegate popedBackFromChild:<some object>]; }tell me if you need further explanation
更多推荐
发布评论