我發現當你在代碼中設置約束時,例如
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:[topLayoutGuide][mainView]"
options:0
metrics:nil
views:@{@"topLayoutGuide" : self.topLayoutGuide, @"mainView" : self.mainView}]];
崩潰有:
2013-10-16 22:23:27.119 Custom Layout Guides[46840:a0b] -[LayoutGuide superview]: unrecognized selector sent to instance 0x8c80c80
2013-10-16 22:23:27.124 Custom Layout Guides[46840:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LayoutGuide superview]: unrecognized selector sent to instance 0x8c80c80'
這很奇怪的是自動佈局嘗試調用superview
在佈局指南,因爲它應該只符合UILayoutSupport
協議。
我也注意到,topLayoutGuide
& bottomLayoutGuide
被聲明爲readonly
:
@property(nonatomic, readonly, retain) id<UILayoutSupport> topLayoutGuide
@property(nonatomic, readonly, retain) id<UILayoutSupport> bottomLayoutGuide
我已經編輯一個鏈接到一個簡單的項目,說明不了什麼如何發生的問題。 –