I created a custom container viewController by using the parent-child model. In the parent I create the child as follows:
// Show Friends view of childs' controller AddFriendViewController
self.friendVC = [[AddFriendViewController alloc] init];
[self addChildViewController:self.friendVC];
self.friendVC.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
[self.view addSubview:self.friendVC.view];
[self.friendVC didMoveToParentViewController:self];
And then in the child's (frienVC) "loadView" I initialized the child's view as follows , and also create a UIView (topBarView) that I will display on the child VC:
- (void)loadView {
self.view = [[UIView alloc]init];
self.view.backgroundColor = [UIColor colorWithHex:SCREEN_ADDFRIENDVIEWCONTROLLER_COLOR];
// Create topBar view
self.topBarView = [[UIView alloc] init];
[self.containerView addSubview:self.topBarView];
}
Now, I am using auto layout constraints to position the "topBarView" in the child's view. And I noticed something really weird. In the " updateViewConstraints
" where I set the position and size of the "topBarView" , the frame of the child's view is (0,0,320,568), which is exactly correct. But in the " viewDidAppear:
" method, which gets called AFTER the " updateViewConstraints
" method, the child's view frame got suddenly changed to (284,160,0,0), which is a TOTALLY random frame.
Why is the system setting the frame of the child's view frame to this after the updateViewConstraints method was called?