0

2つのコンテナ(上に1つ、下に1つ)を格納するViewControllerがあります。トップコンテナには、ボタンとテキストフィールドを備えたViewControllerが格納されています(説明のためだけに)。私がやりたいことは:

  1. テキストを入力
  2. ボタンを押す
  3. bottomViewControllerにテキストを送信します
  4. テーブルに表示

どうすればbottomViewControllerにテキストを送信できますか?どういうわけか親と話をする必要がありますか?

ストーリーボードを使用しているので、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 に答える