When i am placing view of frame size (0.0,0.0,320.0,435.0)
applying auto layout it appears proper in iphone 5 (4 inch) and when i am running in iphone 4s it appears proper due to autolayout but when i am fetching value of its frame after execution during run time it appears "(0.0,0.0,320.0,435.0)"
I cannot get size which have change after applying auto layout in iphone 4s?
I want to get size because using that size i can set programmatically size of custom view created.
Intrinsic content size is information that a view has about how big it should be based on what it displays. For example, a label's intrinsic content size is based on how much text it is displaying. In your case, the image view's intrinsic content size is the size of the image that you selected.
In general, the intrinsic content size simplifies the layout, reducing the number of constraints you need. However, using the intrinsic content size often requires setting the view's content-hugging and compression-resistance (CHCR) priorities, which can add additional complications.
layoutSubviews() The system calls this method whenever it needs to recalculate the frames of views, so you should override it when you want to set frames and specify positioning and sizing. However, you should never call this explicitly when your view hierarchy requires a layout refresh.
Auto Layout constraints allow us to create views that dynamically adjust to different size classes and positions. The constraints will make sure that your views adjust to any size changes without having to manually update frames or positions.
Before your "getting real size code", insert the following code:
yourView.setNeedsLayout()
yourView.layoutIfNeeded()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With