0
我試圖在uiview的下邊距和滾動視圖的下邊距之間設置編程約束。然而,xcode給了我一些錯誤,文本看起來最好不合適,有時它並不出現Swift編程約束下邊距不起作用
所以基本上我有一個尺寸爲400的uview,並將父視圖作爲滾動視圖。 我想在滾動視圖底部和uiview底部之間添加300的距離。我需要以編程方式執行此操作,因爲無法確定屏幕上給定時間將顯示多少視圖,因此我需要以編程方式更改它們之間的約束。
我的代碼是
view.addConstraint(NSLayoutConstraint(
item:container1,
attribute:NSLayoutAttribute.Bottom,
relatedBy:NSLayoutRelation.Equal,
toItem:scrollFrame,
attribute:NSLayoutAttribute.Bottom,
multiplier:0,
constant:400)
)
但它不工作......顯然,在模擬器,UIView的從頂部,或者說定位在400,因爲它的動作下來的時候我增加恆壓(試600)
的Xcode打印以下錯誤:
2015-03-25 12:38:13.342 GraficTest[6612:707546] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7be906b0 V:|-(48)-[UIView:0x7be8e780] (Names: '|':UIScrollView:0x7be90340)>",
"<NSLayoutConstraint:0x7bfd80e0 V:[UIView:0x7be8e780(257)]>",
"<NSLayoutConstraint:0x7bf6a940 UIView:0x7be8e780.bottom == + 600>"
)
你能幫幫我嗎?
非常感謝!
非常感謝,這樣做! – 2015-03-25 13:02:52