Ios 无法同时满足约束-在添加子视图时
我使用的是一个故事板和xib 我从故事板加载了Ios 无法同时满足约束-在添加子视图时,ios,autolayout,Ios,Autolayout,我使用的是一个故事板和xib 我从故事板加载了UIViewController,从xib加载了UIView。我试图将xib作为子视图添加到故事板UIViewController,并将其底部结构设置为: TransactionsPickerViewController *_picker = [[TransactionsPickerViewController alloc] initWithNibName:nil bundle:nil]; [self.view addSubview:picker.v
UIViewController
,从xib加载了UIView
。我试图将xib作为子视图添加到故事板UIViewController
,并将其底部结构设置为:
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>"
)
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。。。
UIView属性translatesAutoresizingMaskIntoConstraints)
(
"",
"",
""
)
那些自动调整大小的属性是从哪里来的?我可以去掉它们使其工作吗?我希望我的选择器视图在添加后粘贴到父视图底部
我试图在xib文件上禁用autolayout,但它没有改变任何东西。您的错误可能是由于未设置
picker.view造成的。translatesAutoresizingMaskIntoConstraints=否将其添加为子视图之前,请执行代码>
但是,在我看来,您应该添加一个TransactionsPickerViewController
作为子视图控制器,而不仅仅是使用它的视图。请参阅部分:和。这似乎可行,但是将autoresizemask设置为NO会导致子视图上的可单击组件不会响应交互,因为它们位于某个位置else@Xylian:正如我在回答中所说,您不应该直接从其他控制器添加视图。改用视图控制器包含。