gpt4 book ai didi

ios - ChildViewController -> ParentViewController -> SecondChildViewController 使用 ContainerView

转载 作者:行者123 更新时间:2023-11-29 04:16:33 25 4
gpt4 key购买 nike

我有一个 ViewController,里面有 2 个容器(一个顶部,一个底部)。顶部容器包含一个带有按钮和文本字段的 ViewController(仅用于说明目的)。我想做的是:

  1. 输入文字
  2. 按下按钮
  3. 发送文本到bottomViewController
  4. 显示到表格中

如何将文本发送到bottomViewController?我必须以某种方式与家长交谈吗?

我正在使用 Storyboard,所以我在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;
}
}

最佳答案

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

关于ios - ChildViewController -> ParentViewController -> SecondChildViewController 使用 ContainerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13617898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com