0
votes

I am designing an iOS app in a landscape orientation. My typical workflow is to use a XIB with universal layout for each view controller. A few view controllers additional programmatic view setup. For this additional setup, I need access to the XIB's subviews final frames before they are drawn on screen.

Example: I have a XIB with one subview that takes up a portion of its parent view. Here is a print out of the subview's frame in the viewDidLoad, viewWillAppear, and viewDidAppear methods..

viewDidLoad:
    - width : 535.0
    - height : 600.0

viewWillAppear:
    - width : 535.0
    - height : 600.0

viewDidAppear:
    - width : 671.0
    - height : 414.0

origins are all (0,0). The additional view setup needs to be done when the subview's width and height is 671.0, 414, but before it is displayed. It should also be noted that (535,600) is the width and height of the subview in the XIB.

1

1 Answers

3
votes

Auto layout will call back to your view controller's viewDidLayoutSubviews. After a pass of the layout engine. This method may be called more than once. By the end of the last call, all of your view controller's subview's frames will be set and pixels will be pushed to the screen.