iOS8 - 约束模棱两可地暗示高度为零 [英] iOS8 - constraints ambiguously suggest a height of zero

查看:19
本文介绍了iOS8 - 约束模棱两可地暗示高度为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何调试吗?

仅警告一次:检测到约束模糊地建议 tableview 单元格的内容视图的高度为零的情况.我们正在考虑无意识的倒塌,而是使用标准高度.

Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.

行具有由设置的固定高度

The rows have a fixed height as set by

- (CGFloat)tableView:(UITableView *)tableView 
           heightForRowAtIndexPath:(NSIndexPath *)indexPath{
   return 34.0;
}

而且所有的约束似乎都很满意...

And all the constraints seem to be happy...

推荐答案

强制返回高度和估计高度使警告在我的情况下消失.

Forcing a return height and estimated height made the warning disappear in my case.

- (CGFloat)tableView:(UITableView *)tableView 
           estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

- (CGFloat)tableView:(UITableView *)tableView 
           heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

另一种不需要两个覆盖的解决方案是在 loadView 或 init 方法中简单地使用 self.tableView.rowHeight = 44;.

Another solution where you don't need the two overrides is simply to use self.tableView.rowHeight = 44; in your loadView or init method.

这篇关于iOS8 - 约束模棱两可地暗示高度为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆