4

Found if use XCode 8 XIB file, the UIView initWithCoder will get frame (0, 0, 1000, 1000) instead of the XIB frame size setting.

Check the diff of XIB xml file it will add

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

and remove rect frame settings such as

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

Removing rect frame setting is the major root cause to get width 1000 and height 1000 in the initWithCoder.

Therefore, any related size calculation, we need to handle in layoutSubviews.

Yang Young
  • 602
  • 5
  • 6

0 Answers0