InitWithCoder XCode8 Frame Size Size

Found if using XIB file Xcode 8, UIView initWithCoder will receive a frame (0, 0, 1000, 1000) instead of setting the size of the XIB frame.

Check the diff xib of the xml file it will add

<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>

and remove the frame settings such as

<rect key="frame" x="110" y="0.0" width="20" height="17"/>

Removing the edge frame setting is the main reason why in initWithCoder get a width of 1000 and a height of 1000.

Therefore, any calculation of related quantities we must process in layoutSubviews.

+4
source share

Source: https://habr.com/ru/post/1655421/


All Articles