Reputation: 10738
How to hide the separatorStyle
from a UITableView
until the table has content. In other words, I would like to show the separator lines only when the table has content.
The way I'm currently doing it is adding it in the cellForRowAtIndexPath
method which I'm not sure if it is the correct place since it's doing it every time a new row is enter.
Is there a better method to implement this? Any suggestions? is the cellForRowAtIndexPath
a bad place?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// code...
myTable.separatorStyle = UITableViewCellSeparatorStyle.SingleLine
myTable.separatorColor = UIColor.myMediumGrayColor()
// code...
}
EDIT: Thanks to @Hems Moradiya's answer below, here is what I did that worked. I moved my code to the viewDidLoad method, as follow.
override func viewDidLoad() {
super.viewDidLoad()
self.myTable.tableFooterView = UIView()
myTable.separatorStyle = UITableViewCellSeparatorStyle.SingleLine
myTable.separatorColor = UIColor.myMediumGrayColor()
}
Upvotes: 1
Views: 59
Reputation: 4815
Add this line in your ViewDidLoad()
self.Eventlisttable.tableFooterView = UIView()
Upvotes: 2