关于Masonary布局与NSAutoresizingMaskL
2017-03-27 本文已影响0人
ZJ_偶尔上路
在项目中出现下面的警告,虽然界面上没出现错误,但是对于有强迫症的程序员来说是难以忍受的。百度后发现一句代码就解决问题了。
[LayoutConstraints] 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)
(
"<MASLayoutConstraint:0x1700b4760 UITextView:0x10083a800.top == UIPlaceholderTextView:0x100414690.top>",
"<MASLayoutConstraint:0x1700b7ca0 UITextView:0x10083a800.bottom == UIPlaceholderTextView:0x100414690.bottom - 23.4859>",
"<NSAutoresizingMaskLayoutConstraint:0x170286bd0 UIPlaceholderTextView:0x100414690.height == 0>"
)
一般情况下加入这句代码就行了:
self.translatesAutoresizingMaskIntoConstraints = NO;