How to get real size UIView with autolayout
Before your "getting real size code", insert the following code:
[view setNeedsLayout];[view layoutIfNeeded];
Since everybody assumes the access is done via a UIViewController
and not inside a UIView
subclass, the answers don't prove really useful. The correct way to get the correct size of a UIView
subclass is in layoutSubviews
.
The simplest solution is to just run that code in -viewDidAppear:
(after autolayout has been run).