小编nic*_*cit的帖子

意外的NSAutoresizingMaskLayoutConstraint的AutoLayout约束问题

我正在以编程方式使用自动布局约束,并且我经常在我的应用程序中看到同样的错误,通常与看起来像这样的约束相关:

"<NSAutoresizingMaskLayoutConstraint:0x82da910 h=--& v=--& V:[UITableViewCellContentView:0x82d9fb0(99)]>"
Run Code Online (Sandbox Code Playgroud)

我在https://github.com/nicolasccit/AutoLayoutCellWarning上放了一些示例代码来重现

在这个例子中,我创建了一个包含2个UI元素的非常简单的视图:一个名为imageThumbnail的图像视图和一个名为labelName的标签,带有一些约束:

"H:|-padding-[_imageThumbnail(==imageWidth)]-[_labelName]";
"V:|-padding-[_imageThumbnail(==imageHeight)]-padding-|";
"V:|-padding-[_labelName]";
Run Code Online (Sandbox Code Playgroud)

在这两个元素上,我将AutoresizingMaskIntoConstraints设置为NO.

我得到以下例外:

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:0xa6e4f90 …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios autolayout

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

autolayout ×1

ios ×1

objective-c ×1

uitableview ×1