我有这段代码:
[parent.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|-(0)-[myView]-(0)-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:@{ @"myView":myView }]];
我可能理解错了,我不知道。我希望myView
遍布parent.view
区域。但我刚收到一个错误:
Unable to simultaneously satisfy constraints.
translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x14d645d0 H:|-(0)-[UIView:0x14d32ce0] (Names: '|':UILayoutContainerView:0x14dbd6a0 )>",
"<NSLayoutConstraint:0x14d64600 H:[UIView:0x14d32ce0]-(0)-| (Names: '|':UILayoutContainerView:0x14dbd6a0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x16184340 h=-&- v=-&-UIView:0x14d32ce0.midX == UILayoutContainerView:0x14dbd6a0.midX + 140>"
)
我试过了@"[myView]-(0)-|"
,但我也遇到了错误。
答案 0 :(得分:2)
您想要设置myView.translatesAutoresizingMaskIntoConstraints = NO