xcode storyboard Container View - How do I access the viewcontroller

前端 未结 5 1944
温柔的废话
温柔的废话 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:25

    If the nib is loaded it will call addChildViewController as part of the initialisation process

    so a performant solution could be also to overwrite

    - (void)addChildViewController:(UIViewController *)childController
    

    there you can catch your childController e.g. by comparing its Class and assign it to a property / ivar

    -(void)addChildViewController:(UIViewController *)childController
    {
        [super addChildViewController:childController];
    
        if([childController isKindOfClass:[InstallViewController class]])
        {
            self.installViewController = (InstallViewController *)childController;
        }
    

    }

    This will save your from iterating trough the childViewControllers.

提交回复
热议问题