为什么UITableViewCell的contentView高度总是比UITableViewCell小一点? [英] Why is contentView height of UITableViewCell always one point smaller than the UITableViewCell?

查看:707
本文介绍了为什么UITableViewCell的contentView高度总是比UITableViewCell小一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的细胞,在UITableViewCell级别,高度为44点。 contentView表示43分,并且在IB中显示为灰色。如何使内容与单元格大小相同?

My cells, at the UITableViewCell level, have a height of 44 points. The contentView says 43 points, and it's greyed out in IB. How can I make the content the same size as the cell?

请注意,我在单独的xib文件中设计单元格。

Note that I'm designing my cells in separate xib files.

我希望我的单元格之间没有边距。

I want my cells to have no margin between each other.

我还将None设置为表视图的分隔符样式。
IB中的行高也设置为44点。不使用任何部分。

I have also set None as separator style of the table view. Row height in IB is also set to 44 points. Not using any sections.

推荐答案

如果您使用故事板设置 tableView的分隔符(而不是默认)摆脱1pt分隔符和contentView的高度等于单元格的高度(即使它变灰)

If you're using storyboards setting the Separator of the tableView to None (instead of Default) gets rid of the 1pt separator and the contentView's height becomes equal to the cell's height (even though it's grayed out)

注意:此解决方案不适用于xib文件(至少不更新IB,没有在运行时检查)。

Note: This solution doesn't work with xib files (at least doesn't update the IB, didn't check at run-time).

这篇关于为什么UITableViewCell的contentView高度总是比UITableViewCell小一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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