Reputation: 12184
I am trying out an application using a child ViewController inside another viewController. I have a VC and I am instantiating another VC with its own xib inside the outer VC.
I am adding it as a child using the new iOS 5 method addChildViewController and also I have added its view as a subView.
But how do I control its position and size inside the parent view controller ?
should I modify the frame of the child controller's view ? or I have to adjust the freeform view in the xib itself ?
Also in my current implementation, the child view starts behind the status bar of the parent viewcontroller's view. Any idea on how to systematically implemement something like this ?
Upvotes: 0
Views: 247
Reputation: 3580
Simply just add a view in parentViewController @synthesize
that view like childView
. now add your childViewController
as a subView in childView
of parentViewController
. it will simple to adjust using parentViewController
View on nib file. If you have a large childViewController
then please use UIScrollView
instad of UIView
Upvotes: 0
Reputation: 3547
#define SUBVIEWS_FRAME CGRectMake(0,20,100,100) // whatever frame you need
- (void)addChildViewController:(UIViewController *)childController{
[childController.view setFrame:SUBVIEWS_FRAME];
[super addChildViewController:childController];
}
Upvotes: 1