线程1:在AppDelegate类上发出SIGBART信号

时间:2016-10-14 18:07:43

标签: ios swift

我最近更新iOS后开始出现此错误。我认为它与我的约束的格式有关,但我无法弄明白。 这是我的错误消息

由于未捕获的异常'NSInvalidLayoutConstraintException'而终止应用程序,原因:'约束不正确地关联不兼容类型的锚:'

这是我的一些约束代码

// Bottom constraint: description
    addConstraint(NSLayoutConstraint (item: descriptionTextView, attribute: .bottom, relatedBy: .equal, toItem: itemImageView, attribute: .bottom, multiplier: 1, constant: 0))

    //right constraint: description
    addConstraint(NSLayoutConstraint(item: descriptionTextView, attribute: .right, relatedBy: .equal, toItem: itemImageView, attribute: .bottom, multiplier: 1, constant: 160))

    //left constraint: description
    addConstraint(NSLayoutConstraint(item: descriptionTextView, attribute: .left, relatedBy: .equal , toItem: itemImageView, attribute: .right, multiplier: 1, constant: 8))

    //height constraint: description
    addConstraint(NSLayoutConstraint(item: descriptionTextView, attribute: .height, relatedBy: .equal, toItem: self, attribute: .height, multiplier: 0, constant: 100))

如何解决线程1:信号SIGBART崩溃?

1 个答案:

答案 0 :(得分:0)

在最后一个addConstraint中:toItem:self - > self.view

addConstraint( NSLayoutConstraint(item: descriptionTextView, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal , toItem: self.view, attribute: NSLayoutAttribute.height, multiplier: 0, constant: 100))