如何从 UITableView
中隐藏 separatorStyle
,直到表格有内容。换句话说,我只想在表格有内容时显示分隔线。
我目前的做法是将它添加到 cellForRowAtIndexPath
方法中,我不确定它是否是正确的位置,因为每次输入新行时它都会这样做。
有没有更好的方法来实现这个?有什么建议么? cellForRowAtIndexPath
是个坏地方吗?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// code...
myTable.separatorStyle = UITableViewCellSeparatorStyle.SingleLine
myTable.separatorColor = UIColor.myMediumGrayColor()
// code...
}
编辑:感谢@Hems Moradiya 在下面的回答,这是我所做的工作。我将代码移至 viewDidLoad 方法,如下所示。
override func viewDidLoad() {
super.viewDidLoad()
self.myTable.tableFooterView = UIView()
myTable.separatorStyle = UITableViewCellSeparatorStyle.SingleLine
myTable.separatorColor = UIColor.myMediumGrayColor()
}
最佳答案
将这一行添加到您的 ViewDidLoad()
self.Eventlisttable.tableFooterView = UIView()
关于ios - 隐藏 separatorColor 直到 UITableView 有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39806649/