xcode storyboard Container View - How do I access the viewcontroller

前端 未结 5 1955
温柔的废话
温柔的废话 2020-12-23 13:02

I\'m trying to use storyboard and get things working properly. I\'ve added a a Container View to one of my existing views. When I try to add a reference to this in my view c

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 13:27

    When you add a container view the xcode calls the UIViewController method addChildViewController:

    In your case, you can get the container ViewController looking for it on the SplashViewController's list of childViewControllers, something like this:

    for (UIViewController *childViewController in [self childViewControllers])
    {
        if ([childViewController isKindOfClass:[InstallViewController class]])
        {
            //found container view controller
            InstallViewController *installViewController = (InstallViewController *)childViewController;
    
            //do something with your container view viewcontroller
    
            break;
        }
    }
    

    I had the same doubt yesterday :)

提交回复
热议问题