简体   繁体   English

UITableView - 单元格之间的行

[英]UITableView - Lines Between Cells

I have a UITableView that has cells of which, for this example, let's say only the top two are filled. 我有一个UITableView ,其中包含其中的单元格,例如,假设只填充了前两个单元格。 For the rest of the cells going down the list there are still separator lines. 对于列表中的其余单元格,仍然存在分隔线。

Is there a way to turn the lines off where there are empty cells but keep them on to separate cells that contain information? 有没有办法在有空单元格的地方关闭这些线,但是要将它们分开以分隔包含信息的单元格?

No there is no built in support for this. 没有内置的支持。

You could turn off the cells on the table view with: 您可以使用以下命令关闭表视图上的单元格:

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

And then draw the separator lines in your own UITableViewCell subclasses that you use for the rows. 然后在您用于行的UITableViewCell子类中绘制分隔线。

另一个简单的黑客是将它添加到UITableViewControllers viewDidLoad方法:

    self.tableView.tableFooterView = [UIView new];

还有一种方法是在viewdidLoad中编写行

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

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

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