我用一个场景制作了一个故事板。在我的UIViewController
中,我使用SnapKit定义了以下内容:
@IBOutlet weak var emailTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
emailTextField.snp_makeConstraints { (make) -> Void in
make.size.equalTo(CGSizeMake(100, 40))
}
}
我一直收到错误:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
我已尝试过snp_remakeConstraints
和snp_updateConstraints
但错误相同。
我在这里做错了什么?
感谢。
答案 0 :(得分:0)
发生问题,因为SnapKit仅删除了emailTextField
自己的约束(通过自动设置translatesAutoresizingMaskIntoConstraints = false
),因此仍然存在一些重复项。
对于情节提要约束,您需要清除所有默认约束。您可以使用以下代码来实现:
yourTextFieldsSuperviewName.removeConstraints(view.constraints)
祝你好运!