When I use a subclass of UIView
and put it on the storyboard with some constraints,i check its frame in awakeFromNib()
or didMoveToWindow()
. The result is not correct cause the constraints are not applied yet.
Is there any callback to inform me that the constraints are applied? So after that i can do sth with the correct frame.
When awakeFromNib
viewDidLoad
or didMoveToWindow
is called, layout is not completed yet. You have to use viewDidLayoutSubviews
of a viewController. This method will be called after applying constraints and completing layout.
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.