SomeViewController *someVC = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
self.someViewController = someVC;
[someVC release];
NSLog(@"height before added as subview: %f", self.someViewController.view.frame.size.height);
[self.containerView addSubview:self.someViewController.view];
NSLog(@"height AFTER added as subview: %f", self.someViewController.view.frame.size.height);
// height before added as subview: 480.000000
// height AFTER added as subview: 540.000000
What possible explanation is there for this? someViewController’s view does not have any autoresizing properties set, and containerView does not autoresize it’s subviews. What could cause the frame to change by just adding it as a subview?
A further mystery to this is that it only happens when someViewController’s view height is >= 480.
What kind of view controller is
SomeViewController? The one thing I think that may be happening isSomeViewControllermay contain some extra content such as the top bar of anUINavigationControllerand that is automatically increasing the size sometimes. But what you are doing is violating the HIG by adding the view of one view controller to another view controller. AnUIViewControlleris designed to be the full view of the screen or belonging to a specialized view controller such as anUITabBarController,UINavigationController, orUISplitViewController. As a resultsomeViewControllerwill not function as expected and not receive calls such asviewDidLoad. So if you are sure that no autoresizing properties are set all I can recommend is using anUIViewinstead of anUIViewController.