I have a UIViewController
which loads a subview from a nib and adds it to a subview in its view hierarchy. Now this is working all fine in the iPhone story board, but in the iPad one although I do see the view but as the viewWillAppear
is not called the UIImageView
on the view is not initialised.
Here's the code from the main viewcontroller (the one that loads the subview)
SubViewController *controller = [[SubViewController alloc] init];
NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:@"x"] owner:controller options:nil];
UIView *subView = bundle[0];
[self addChildViewController:controller];
if (isPhone)
{
CGRect frame;
frame.origin.x = 0;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
view.frame = frame;
[self.scrollView addSubview:view];
}
else
{
view.frame = self.viewSlot.frame;
[self.viewSlot addSubview:view];
}
The only difference is on the iPhone it is added to a UIScrollView
whereas on the iPad it is added to a UIView
.
viewSlot
and scrollView
are both outlets which are properly initialised and work. Even on the iPad I do see my view (I've changed its background colour) it's only the initialisation (viewWillAppear
) that does not run.