1
我在xib中使用了一個故事板。無法同時滿足約束 - 同時添加子視圖
我有從故事板加載的UIViewController
和從xib加載的UIView
。我想補充廈門國際銀行作爲一個子視圖,以故事情節UIViewController
,並設置它的底部constratint這樣的:
TransactionsPickerViewController *_picker = [[TransactionsPickerViewController alloc] initWithNibName:nil bundle:nil];
[self.view addSubview:picker.view];
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:picker.view
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeBottom
multiplier:1.0f constant:0.0f];
[self.view addConstraint:constraint];
它會導致這個在調試控制檯:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want...
UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x1090509e0 UIView:0x109440be0.bottom == UIView:0x109619ba0.bottom>",
"<NSAutoresizingMaskLayoutConstraint:0x109052400 h=-&- v=-&- UIView:0x109440be0.midY == UIView:0x109619ba0.midY - 140>",
"<NSAutoresizingMaskLayoutConstraint:0x109052470 h=-&- v=-&- UIView:0x109440be0.height == UIView:0x109619ba0.height - 280>"
)
那些人在那裏自動調整性能來自和我可以擺脫他們,使其工作?好吧,我想我的選擇器視圖粘在添加後的父視圖底部。
我試圖禁用xib文件的自動佈局,但它不會改變任何東西。
這似乎工作,但是將autoresizemask設置爲NO,導致子視圖上的可點擊組件不響應交互,因爲它們躺在別處 –
@Xylian:正如我在我的回答中所說的,您不應該添加視圖不同的控制器直接。改用視圖控制器遏制。 –
沒有,工作得很好,謝謝:) –