Reputation: 4646
I have a UiView called TestView which I have added as a subView of my NumberViewController.
On start of my app, My rootViewController is PaperViewController, this has some UIButtons which I have added through xib, Now I wanted to add NumberViewController's view as a subView of PaperViewController, so I did this
NumberViewController = [[NumberViewController alloc] initWithNibName:@"NumberViewController" bundle:nil];
NumberViewController.delegate = self;
[self.view addSubview:NumberViewController.view];
NumberViewController.view.backgroundColor = [UIColor clearColor];
NumberViewController.view.hidden = YES;
Now this is hidden because, I will unhide it on click of some button and then I will show NumberViewContrller's view.This all works fine.
But suppose I added some buttons in PaperViewController through code, and then unhide NumberViewController's view , then both views overlap.
I am not understanding what is the problem, and what mistake I am making. So friends please help me out
Regards Ranjit.
Upvotes: 1
Views: 1495
Reputation: 177
Add UIView in Header:
@property (weak, nonatomic) IBOutlet UIView *addChildView;
In - (void)viewDidLoad
- Method do this:
ChildViewController *nonSystemsController = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
nonSystemsController.view.frame = self.addChildView.bounds;
[self.addChildView addSubview:nonSystemsController.view];
[nonSystemsController didMoveToParentViewController:self];
[self addChildViewController:nonSystemsController];
Upvotes: 2