Does this issue occur on iOS 7 or iOS 8? Or both?
UITableView
in iOS uses a concept of "recycling" the banknotes. Every time you use scroll of the table view it reloads the ballots. You can solve this problem in a few different ways.
If you are on iOS 7, you can reset the tab style of the table view
Using the delegate methods of table you redefine the style of the banknotes.
func tableView(tableView: UITableView, didHighlightRowAtIndexPath indexPath: NSIndexPath) {
// Redefinindo o estilo do separador
tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;
}
func tableView(tableView: UITableView, didUnhighlightRowAtIndexPath indexPath: NSIndexPath) {
// Redefinindo o estilo do separador
tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Redefinindo o estilo do separador
tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Por garantia também redefine o estilo do separador ao selecionar a cédula
tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;
}
If you use customized ballots
You have to register the ballot in viewDidLoad
.
self.tableView.registerClass(CustomClassCell.classForCoder(), forCellReuseIdentifier: "Cell")
More drastic solution if none of these works
You can add a% color of% gray with height of UIView
to the bottom of the ballot and remove the style of the separator, setting the style to 1
. But it would not be the best practice.
EDIT
Solution with ballots loaded from a nib
To create the ballot from a Nib, in viewDidLoad you must register the identifier of it:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerNib(UINib(nibName: "CellNibName", bundle: nil), forCellReuseIdentifier: "Cell")
}
In the None
method:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomClassCell
.
.
.
return cell
}