我得到了一個奇怪的問題,我的NSLayoutConstraint。ios 8.3 NSLayoutAttributeNotAnAttribute崩潰
我最近更新了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上崩潰。
我錯過了什麼嗎?
它「正在工作」如何?你永遠不可能將事物的_top_設置爲絕對值。我不知道你的代碼在幹什麼,但總是錯的。 – matt
我有一個叫做三角形的子視圖,它是自定義視圖的子視圖。我正在使用此動畫約束來更改三角形子視圖的Y座標。我將如何使用正確的方式去實現我想要的東西,請賜教matt – Zhang
您設置'self.triangle'的頂部__與其他東西相關,比如它的頂層視圖(它不會被_have_成爲superview的頂部,這只是一個特別常見的事情,所以我用它作爲例子)。 – matt