在viewdidload中无法修改view的frame问题

在viewdidload中无法修改view的frame问题
 

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 loadViewreturns, 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.

你可能感兴趣的:(frame)