奇怪的自动布局问题

时间:2018-05-30 02:33:55

标签: ios xcode autolayout

根据上一个问题,我仔细了解了Autolayout。在实践项目中,一切都在viewController中正常运行。但它真的不适用于我自己的tableView单元格。奇怪的事情继续下去,我感到非常绝望。

I have a tableviewcell with two labels.

All the constraints were settled, xcode reads blue lines.

Blue lines shown normal in xcode

但是一旦我运行该程序,标签就会挤在x = 0,y = 0的内容视图中。This is so weired

This is the label attribute settings

This is tableview cell settings This is tableview cell setting too

这是身高的代码:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    if indexPath.section == 1 {
    return 100
    } else {
    return 40
    }
}

对于以上所有,我设置x,y,高度,宽度,应该没有任何东西。但它真的不起作用。我已经陷入困境好几天了。我怎么能解决这个问题?

更新:

我在&#34上添加了一个约束;这是一个标签"标签:领先空间到第一个标签。此外,我还缩小了第二个标签的内容拥抱和压缩优先级,以便完整显示常量字。 Added constraint and modified priority

我无法上传超过8个链接,所以很遗憾我无法上传更新的图片。

但这两个标签仍然合并。还有什么我仍然缺少吗?

UPDATE2:

我通过删除tableViewController解决了这个问题,并重建了一个新的。它有效,但我真的不知道旧的发生了什么。

0 个答案:

没有答案
相关问题