So I have a UIViewController inside a UIViewController and inside a UIViewController and I am trying to adjust its frame. However when I call setFrame:, it calls the viewDidLoad of that particular view controller I am trying to adjust the frame. However at that time the frameSize isn't the one that I set. In this viewDidLoad I am also calling a private method called loadDataFromServer, which pulls in data from memory first and then make a call to the server. Because it's loading data from memory, it does it really quick, basically before viewDidLoad is finished and therefore the frame size hasn't been adjusted yet. So I see the view with the wrong size/layout first and then it adjusts after getting data from the server, which at this point viewDidLoad is finished and the frame is adjusted well.
If I move the loadDataFromServer call to viewDidAppear then it all looks fine. The thing is that I am not sure when viewDidAppear is called. Is it called after viewDidLoad once? Or is it called after viewWillAppear? Any idea/work around for this?
ContainerViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContainerViewController"];
vc.delegate = self;
UINavigationController *newsfeedNavController = [[UINavigationController alloc] initWithRootViewController:vc];
[self addChildViewController:newsfeedNavController];
newsfeedNavController.view.frame = CGRectMake(0, 0, self.view.frameWidth, self.view.frameHeight);
[self.view addSubview:newsfeedNavController.view];
[newsfeedNavController didMoveToParentViewController:self];
[newsfeedNavController release];