2012-11-29 2 views
0

2 개의 컨테이너 (상단, 하단 각각 하나씩)가있는 ViewController가 있습니다. Top Container에는 버튼과 텍스트 필드가있는 ViewController가 있습니다. 내가하고 싶은 것입니다 : ChildViewController -> ParentViewController -> SecondChildViewController (ContainerView 사용)

  • 디스플레이 테이블에 bottomViewController에

    1. 텍스트를 입력
    2. 버튼을 누르면
    3. 보내기 텍스트는

    어떻게 bottomViewController에 텍스트를 보내려면 어떻게합니까? 어떻게 든 부모와 이야기해야합니까? 나는 스토리 보드를 사용하고

    그래서 당신은 삽입 그런 segues 사용하지 않는 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; 
        } 
    } 
    
  • 답변

    1

    이 있습니다. 2 개의 컨트롤러는 상위 컨트롤러와 동시에 인스턴스화됩니다. 상위 컨트롤러의 childViewControllers 속성에서이 두 자식 컨트롤러에 대한 참조를 가져올 수 있습니다. childViewController를 로그하여 배열의 어느 멤버가 어떤 컨트롤러인지 확인한 다음 해당 컨트롤러를 self.childViewController [0], self.childViewControllers [1]로 참조 할 수 있습니다.