4
在UIView.h您可以閱讀以下內容:translatesAutoresizingMaskIntoConstraints和IB
/* by default, the autoresizing mask on a view gives rise to constraints
that fully determine the view's position. Any constraints you set on
the view are likely to conflict with autoresizing constraints,
so you must turn off this property first. IB will turn it off for you.
*/
- (BOOL)translatesAutoresizingMaskIntoConstraints NS_AVAILABLE_IOS(6_0); // Default YES
因此,這意味着,當你從廈門國際銀行創建UIView
,translatesAutoresizingMaskIntoConstraints
應設置爲NO
。
但是,當我使用[[UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]] instantiateWithOwner:self options:nil]
創建一個xib視圖時,translatesAutoresizingMaskIntoConstraints
設置爲YES
。
任何想法爲什麼?
如果在nib中設置複選標記AutoLauOut,則將設置translatesAutoresizingMaskIntoConstraints –
已檢查xib文件中的「Use Autolayout」複選框。 – MartinMoizard
@MartinMoizard,你發現答案了嗎? – Blaz