简体   繁体   English

iPhone:UITableView中不存在的单元格之间的白线

[英]iPhone: white lines in UITableView between nonexistent cells

alt text http://img179.imageshack.us/img179/2047/iphonetableview.png alt text http://img179.imageshack.us/img179/2047/iphonetableview.png

I have a UITableView within a nib file. 我在nib文件中有一个UITableView。 It works perfectly with 4 or more cells. 它与4个或更多细胞完美配合。 When I have only 2 or 3 cells and the screen is not completely filled with cells I have these empty cells (dark gray, which is actually just the background of my TableView) at the bottom. 当我只有2或3个单元格并且屏幕没有完全充满单元格时,我在底部有这些空单元格(深灰色,实际上只是我的TableView的背景)。

However, they shouldn't be there, because my numberOfSectionsInTableView and numberOfRowsInSection returns the correct values. 但是,它们不应该存在,因为我的numberOfSectionsInTableViewnumberOfRowsInSection返回正确的值。

Any ideas? 有任何想法吗?

What you see is the default behaviour of UITableViewStylePlain . 你看到的是UITableViewStylePlain默认行为 If you don't want to have "empty cells" below your real cells, move the "More" button (seen in your pic) into UITableView tableFooterView. 如果您不希望真实单元格下方有“空单元”,请将“更多”按钮(在图片中看到)移动到UITableView tableFooterView中。 When you don't have "More" button and still don't want "empty cells", create an empty footer: 当您没有“更多”按钮但仍然不想要“空单元格”时,请创建一个空页脚:

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

For some reason existance of tableFooterView removes "empty cells" after the real cells. 由于某些原因, tableFooterView的存在会删除真实单元后面的“空单元格”

I don't think they are actually cells. 我不认为它们实际上是细胞。 You are seeing the white lines because this is the default behavior for the table view. 您正在看到白线,因为这是表视图的默认行为。 Have you tried changing the separator for the table view to none in IB? 您是否尝试在IB中将表视图的分隔符更改为无?

alt text http://img.skitch.com/20100513-x5428pkyp8iaqchmkrd41h8m98.png 替代文字http://img.skitch.com/20100513-x5428pkyp8iaqchmkrd41h8m98.png

I've seen that too. 我也见过。 I guess if you don't like it then when you have only 2 or 3 cells, make a 3rd (or 4th) which is blank and non selectable to cover the remainder of the space. 我想如果你不喜欢它,那么当你只有2或3个单元格时,制作一个空白且不可选择的第3个(或第4个)来覆盖剩余的空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM