The viewDidLoad
method is too early to set your view's frame because something else is changing the frame later.
For example, if this is your root view controller, then the UIWindow
object will set the view's frame when it adds the view to itself as a subview. The viewDidLoad
method runs as soon as loadView
returns, before any outside object (like the UIWindow
) can get its hands on the view.
You can test this by using a custom view (if you're not already) and overriding setFrame:
in the custom view class:
1 - (void)setFrame:(CGRect)frame { 2 [super setFrame:frame]; 3 }
Put a breakpoint in that method and you'll see that the view's frame gets set some time after viewDidLoad
returns.