将UITableViewCell推出视图会破坏约束

时间:2015-03-11 14:00:35

标签: ios xcode uitableview swift

我创建了一些原型单元格来在UITableView中显示我的数据。我目前使用的原型单元有

  • 团队名称的两个标签
  • 每个团队的两张图片(徽标)
  • 具有灰色背景的UIView,其中包含:

    • 每个团队得分的两个标签
    • 带有用于分数分隔的冒号的标签

在接口生成器中放置约束的一些初始问题之后,我设法创建(可能是)无冲突的布局约束来保持一切就绪。在模拟器(iPhone 5)中,一切都像预期的那样工作,但是只要我将它加载到我的物理iPhone 5中就会出现问题。

起初一切看起来都不错(左图)。一旦我在视图外(第二张图像)滑动其中一个TableViewCell,一些约束就会中断,隐藏外部两个标签并更改单元格高度(第三张图像)。 - 当我在模拟器中运行应用程序时,这不会发生。

一旦将细胞推到可见视野之外,就会发生这种情况。

Demo of the constraint break

这些是我在控制台中收到的警告:

2015-03-11 14:44:44.282 MSUapp[1280:942149] 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:0x155f5170 H:[UIView:0x155f3fe0(50)]>",
    "<NSLayoutConstraint:0x155f5580 UIImageView:0x155f54d0.width == UIImageView:0x155f54d0.height>",
    "<NSLayoutConstraint:0x155f5bf0 UILabel:0x155f5820'1. FC K\U00f6ln'.leading == UITableViewCellContentView:0x156ed850.leadingMargin - 7>",
    "<NSLayoutConstraint:0x155f5c50 H:[UILabel:0x155f5820'1. FC K\U00f6ln']-(15)-[UIImageView:0x155f54d0]>",
    "<NSLayoutConstraint:0x155f5cb0 UIView:0x155f3fe0.top == 0.4*UITableViewCellContentView:0x156ed850.centerYWithinMargins>",
    "<NSLayoutConstraint:0x155f5ce0 UIView:0x155f3fe0.bottom == 1.6*UITableViewCellContentView:0x156ed850.centerYWithinMargins>",
    "<NSLayoutConstraint:0x155f5d10 H:[UIImageView:0x155f54d0]-(5)-[UIView:0x155f3fe0]>",
    "<NSLayoutConstraint:0x155f5d40 UITableViewCellContentView:0x156ed850.centerX == UIView:0x155f3fe0.centerX>",
    "<NSLayoutConstraint:0x155f5d70 UIView:0x155f3fe0.height == UIImageView:0x155f54d0.height>",
    "<NSLayoutConstraint:0x1552a0c0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x156ed850(320)]>",
    "<NSLayoutConstraint:0x1552a090 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x156ed850(178.5)]>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x155f5580 UIImageView:0x155f54d0.width == UIImageView:0x155f54d0.height>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

这是我的约束列表(我无法扩展它,因此文本的末尾被裁剪):

Constraints list Storyboard

预览模板表示约束,例如没有任何警告说任何事情都是错位的。

我该怎么做才能防止这种情况发生?如果您需要任何其他信息,请与我们联系。任何帮助表示赞赏!

更新 我刚刚更改了一些约束,并将之前测试的iPhone 5更新为iOS 8.3 beta。现在它正在努力。但是,当我在iPhone 6(运行iOS 8.1.3)上试用它时,问题仍然存在。因此它似乎是iOS版本特定的。它有什么修复方法吗?

0 个答案:

没有答案
相关问题