Upvote:-1

Aprove answer

For posterity: the problem I was having -- getting incorrect values when printing the frame of a view -- was caused by accessing that frame during ViewDidLoad. At this point in the ViewController lifecycle all views may have not been laid out.

Therefore, it is safest to access a UIView property/outlet only after ViewDidLayoutSubviews has been called.

I mean, it's right there in the name of the method: "Your views have been laid out... now do stuff with them."


Credit Goes to: stackoverflow.com

Related question with same questions but different answers