Access Container View Controller from Parent iOS

后端 未结 11 2210
遥遥无期
遥遥无期 2020-11-28 18:13

in iOS6 I noticed the new Container View but am not quite sure how to access it\'s controller from the containing view.

Scenario:

11条回答
  •  眼角桃花
    2020-11-28 18:23

    Yes, you can use the segue to get access the child view controller (and its view and subviews). Give the segue an identifier (such as alertview_embed), using the Attributes inspector in Storyboard. Then have the parent view controller (the one housing the container view) implement a method like this:

    - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
       NSString * segueName = segue.identifier;
       if ([segueName isEqualToString: @"alertview_embed"]) {
           AlertViewController * childViewController = (AlertViewController *) [segue destinationViewController];
           AlertView * alertView = childViewController.view;
           // do something with the AlertView's subviews here...
       }
    }
    

提交回复
热议问题