UITableViewCellContentView宽度根据自动调整大小掩码始终为零(仅在iOS 7上)
我正在使用动态单元高度的自动布局方法,如中所述。到目前为止,这是可行的。现在,我在一个UITableViewCellContentView宽度根据自动调整大小掩码始终为零(仅在iOS 7上),uitableview,ios7,autolayout,uipopovercontroller,autoresizingmask,Uitableview,Ios7,Autolayout,Uipopovercontroller,Autoresizingmask,我正在使用动态单元高度的自动布局方法,如中所述。到目前为止,这是可行的。现在,我在一个UIPopoverController中演示我的UITableView,它也可以工作。现在来看有趣的部分:我将从不同的视图控制器演示这个popover。在第一个视图控制器上,一切正常。如果我切换到第二个视图控制器,它也提供了这个popover,popover是完全空的(即使没有分隔线!),我会得到以下错误: Unable to simultaneously satisfy constraints. Pr
UIPopoverController
中演示我的UITableView
,它也可以工作。现在来看有趣的部分:我将从不同的视图控制器演示这个popover。在第一个视图控制器上,一切正常。如果我切换到第二个视图控制器,它也提供了这个popover,popover是完全空的(即使没有分隔线!),我会得到以下错误:
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:0x7a706fa0 H:|-(8)-[UILabel:0x7a707760] (Names: '|':UITableViewCellContentView:0x7a707ba0 )>",
"<NSLayoutConstraint:0x7a707060 H:[UILabel:0x7a707760]-(8)-| (Names: '|':UITableViewCellContentView:0x7a707ba0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x7a706970 h=--& v=--& H:[UITableViewCellContentView:0x7a707ba0(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7a707060 H:[UILabel:0x7a707760]-(8)-| (Names: '|':UITableViewCellContentView:0x7a707ba0 )>
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.
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
""
)
将尝试通过打破约束进行恢复
在objc_异常_抛出时中断,以便在调试器中捕获该异常。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
现在我们关注这一部分:
"<NSAutoresizingMaskLayoutConstraint:0x7a706970 h=--& v=--& H:[UITableViewCellContentView:0x7a707ba0(0)]>"
“”
它表示根据自动调整大小掩码,UITableViewCellContentView
的宽度为零。但是以前,相同的代码在另一个视图控制器上工作。popover应该独立于我在视图控制器中的设置。我试图在另一个项目中复制这种行为,但我做不到。这也仅出现在iOS 7上。在iOS 8上,一切正常。我还试图摆脱自动布局,然后显示内容(但不是以我想要的方式)。我能想到的唯一选择是回到弹簧和支柱。。。如果你愿意,我可以用C#提供我的代码,但我省略了它以使问题更具可读性
这可能是什么原因?有人经历过这样的事情吗?在搜索了一天之后,因为这是一个人可能犯的默认错误。因为我以前的控制器不在popover中,所以下面的代码行仍然存在:
myViewControllerInPopup.View.TranslatesAutoresizingMaskIntoConstraints = false;
我在视图控制器上有这个,它实例化了popover。拆下这条线,一切正常