Reputation: 2830
A subview I have which is taking up the entire view width and defined on the storyboard has a different size at runtime. The size on the screen does not correlate to the size when myView.frame.size.width
is called on the view in viewDidLoad()
. How can I get this size?
Upvotes: 0
Views: 144
Reputation: 39081
viewDidLoad()
does not lay out the views, they only get loaded, if you print out any subview's superview
you will get nil
. In viewDidLayoutSubviews()
your view lays out the subviews with the correct size after AutoLayout
.
Upvotes: 4
Reputation: 797
I think that when the method viewDidLoad()
is called, the views are loaded but not laid out. Maybe you should call myView.frame.size.width
in viewWillAppear()
Upvotes: 1