Skip to content

Instantly share code, notes, and snippets.

@thornpig
Created January 20, 2016 20:27
Show Gist options
  • Save thornpig/dca4383c8494bae3a5ee to your computer and use it in GitHub Desktop.
Save thornpig/dca4383c8494bae3a5ee to your computer and use it in GitHub Desktop.
Work around for the problem: Frame of container view is not right when its frame is setup via autolayout
-(void)viewDidLayoutSubviews
{
self.containerView.frame = self.view.bounds;
self.currentVC.view.frame = self.containerView.bounds;
}
-(void)showChildViewController:(UIViewController *)childVC
{
[self addChildViewController:childVC];
self.containerView.frame = self.view.bounds;
self.currentVC.view.frame = self.containerView.bounds;
[self.containerView addSubview:childVC.view];
[childVC didMoveToParentViewController:self];
self.currentVC = childVC;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment