2
votes

I'm creating a custom container view controller but when I want to resize the frame of one of the child viewcontroller's view its size is not good regarding the orientation of the screen.

To be more precise in the init method of my container I retain 2 instance variable (2 viewcontrollers). Then in the viewdidload method of my container, I want to resize the frame of the view of one viewcontroller and add the 2 as subviews.

My problem is that I'm working in landscape orientation only and when I ask the frame size of one of the viewcontrollers, the height and the width are reversed. I should have a width of 1024 and a height of 748 but I get a width of 748 and a height of 1024 !

Do you know why ?

PS : in all the viewcontrollers including the container viewcontroller I set the shouldautorotate method to UIOrientationInterfaceIsLandscape()

Thanks a lot

1

1 Answers

7
votes

I'm not sure of your exact setup, but here's some general info that may help:

When you have view controllers very near the top of the view hierarchy (or indeed at the top) you can find that you get this 'swapping' effect of the width and height. The swapping usually manifests itself on the frame, but not on the bounds of the view. This is because bounds is effectively some transformations applied to the frame -- and sometimes these transformations include a 90 degree rotation (due to device being in landscape mode).

Note that the exact timing of when you check the frame property can be important too. If you're checking the property after the view loaded but before it has appeared on-screen, you can get the 'wrong' result.