在運行良好的應用程序中,我只是在代碼和故事板中完成了字符串翻譯,然後出現'無法同時滿足約束'錯誤。字符串翻譯後AutoLayout約束衝突
的錯誤是:
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:0x1d5408d0 V:[UIView:0x1d540c40(0)]>",
"<NSLayoutConstraint:0x1d540910 V:|-(0)-[UIView:0x1d540c40] (Names: '|':UIView:0x1d541100)>",
"<NSLayoutConstraint:0x1d540fd0 V:[UILabel:0x1d541040(21)]>",
"<NSLayoutConstraint:0x1d5407d0 V:[UIView:0x1d540c40]-(20)-[UILabel:0x1d541040]>",
"<NSLayoutConstraint:0x1d540710 V:[LTSelectView:0x1d542210]-(360)-| (Names: '|':UIView:0x1d541100)>",
"<NSAutoresizingMaskLayoutConstraint:0x1d5928b0 h=--& v=--& V:[UIView:0x1d541100(416)]>",
"<NSLayoutConstraint:0x1d540690 V:[UILabel:0x1d541040]-(19)-[LTSelectView:0x1d542210]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1d540fd0 V:[UILabel:0x1d541040(21)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
是否翻譯某處負責呢?
我在這個主題上讀了幾篇文章,但理由對我來說真的不容易理解。
所以我的對象是:
的UILabel: 高度等於21 寬度等於:220 頂部空間頂部佈局:17 居中X到:上海華 底部的空間來選擇查看:22
LTSelectView: 寬度等於:160 高度等於:30 對齊中心X到:超級視圖 頂部空間到UILabel:22 底部空間到UIButton:67
的UIButton: 寬度等於:100 高度等於:30 頂部空間來選擇查看:67 對齊中心:上海華
事實上,我可以看到的UILabel,在UIButton的但不是LTSelectView 。所以問題肯定在這裏。 我使用obj_exception_throw,但我沒有得到任何東西。
經過其他測試,我只在iOS6的問題。事情在iOS7上運行良好。
您是否在代碼中添加了約束?有這個'NSAutoresizingMaskLayoutConstraint',看起來你忘了將'translatesAutoresizingMasksToContraints'設置爲NO。 – dasdom 2014-09-19 14:57:46
不,我沒有在代碼中添加任何約束,並且有疑問,我在viewDidLoad方法中添加了這一行,其結果是純粹的噩夢!再也沒有什麼東西在正確的位置。 – 2ndGAB 2014-09-19 15:13:33
然後我的答案是:你的約束是不正確的。 – dasdom 2014-09-19 15:53:57