0

I have a ViewController that houses 2 Containers (one top, one bottom). Top Container houses a ViewController with a button and a textfield (just for illustrating purposes). What I want to do is:

  1. Type text
  2. Press button
  3. Send text to bottomViewController
  4. Display into table

How do I send text to the bottomViewController? Do I somehow have to talk to the parent?

I'm using Storyboards so I have this in the parentViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSLog(@"Current Segue: %@", segue.identifier);
    if ([segue.identifier isEqualToString:@"topSegue"]) {
        self.enterCommentViewController = segue.destinationViewController;
    }
    else if ([segue.identifier isEqualToString:@"bottomSegue"]) {
        self.commentsViewController = segue.destinationViewController;
    }
}
4

1 回答 1

1

你不使用这样的嵌入转场。2 个控制器与父控制器同时实例化。您可以从父控制器的 childViewControllers 属性中获取对这 2 个子控制器的引用。您应该记录 childViewControllers 以查看数组的哪个成员是哪个控制器,然后您可以将这些控制器称为 self.childViewControllers[0] 和 self.childViewControllers[1]。

于 2012-11-29T02:56:31.997 回答