简体   繁体   English

iOS TableView中表格的最后一个单元格缺少分隔符

[英]ios tableview last cell in table missing separator swift

My table view's last cell was working fine and showing a separator. 我的表格视图的最后一个单元格运行良好,并显示了一个分隔符。 However when testing my app now I realized that the separator no longer comes up anymore for the last cell of the table. 但是,现在在测试我的应用程序时,我意识到对于表的最后一个单元格不再出现分隔符。 The only thing I can think of that might have caused this to happen was playing around with some of the preset tableview settings in main.storyboard.I checked but didn't notice anything different. 我唯一想到的可能是导致这种情况发生的原因是在main.storyboard中使用了一些预设的tableview设置。我检查了但没有发现任何不同。 Any one know what I might have changed to cause this, or now what to try to fix it ? 任何人都知道我可能已经更改以导致此问题的原因,或者现在知道如何解决该问题? Thank you 谢谢

By default, the last cell of a tableView does not show a separator. 默认情况下, tableView的最后一个单元格不显示分隔符。 Someway to work around it include using a 1px UIView with background Color as separator. 解决该问题的方法包括使用1px UIView和背景色作为分隔符。

The other way I prefer doing is to set a footer view. 我更喜欢做的另一种方法是设置页脚视图。 Something like this: 像这样:

    self.tableView.tableFooterView = UIView(frame: CGRect.zero)

By setting a tableFooterView the last cell would show a separator. 通过设置tableFooterView ,最后一个单元格将显示一个分隔符。

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

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