I have created 2 child views inside my view controller to be swapped between each other based on 2 different buttons.
a la, button 1 shows childview1 etc.
However, when I start the app in landscape mode and print out the bounds for the childviews in viewDidAppear, the bounds are still incorrect.
So basically,
-
In view controller’s viewDidAppear method, i create 2 childviews, then i immediately print out bounds here for the viewcontroller. they are correct.
-
In the childviewcontroller’s viewDidAppear method, i also print out the bounds AFTER i know they are correct for the parent and they are still incorrect.
so the output looks like this..
ViewController Bounds Height2:748.000000 Width: 1024.000000
Child Bounds Height:1004.000000 Width: 768.000000
and when the app loads, my viewcontroller has correct dimensions, and the childs do not.
Any ideas? is there some way to set the childs boundaries on creation?
Thanks
I think the problem is that you never set your child view controllers’ views’ frames from anywhere outside of the child view controllers. Within your parent view controller’s
viewDidLoadmethod (or theviewDidAppearmethod, if you like) and after the child view controllers have been initialized, set their frames using the parent view controller’sbounds.For example, you might put the following in your parent view controller’s
viewDidLoadmethod: