我的 NSLayoutConstraint 遇到了一个奇怪的问题。
我最近将我的 iPhone 更新到 8.3 并使用最新的 Xcode。
该应用程序在 iOS 8.3 上崩溃,断点指向我:
self.triangleTopConstraint = [NSLayoutConstraint constraintWithItem:self.triangle
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:0.0];
[self addConstraint:self.triangleTopConstraint];
这在 iOS 8.3 之前有效。
但是,我在此页面上阅读:
它说NSLayoutAttributeNotAnAttribute
在关系没有第二视图时使用。所以我把它改成这样:
self.triangleTopConstraint = [NSLayoutConstraint constraintWithItem:self.triangle
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1.0
constant:0.0];
[self addConstraint:self.triangleTopConstraint];
但该应用程序仍然在 iOS 8.3 上崩溃。
我错过了什么吗?