Good Evening
I have a UITableView with custom cells, which behaves weird and I can't find the solution. So my table points to the controller and uses it as dataSource. Here is the code to retrieve cells
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let tempCell = tableView.dequeueReusableCellWithIdentifier(armPointCellIdentifier, forIndexPath: indexPath) as! AircraftTableCell
tempCell.hidden = false
tempCell.UILabel_aircraftName.text = "CELL #\(indexPath.row) : \(tempCell)"
print("\(indexPath.row): \(tempCell)")
return tempCell;
}
When I scroll, cells appear and disapper. I never get nils in the print-out. Here is before scrolling up and down:
And here is after
I tried googling, but nothing helps...
Update 1
So I tried debugging based in suggestion that the items get 0 height, or get moved under other items. But I actually have empty views for some cells. Here is sample debug output. You can see that one cell has switch and label, and the other doesn't. I hope somebody knows what to do :((
Change it to
let tempCell = tableView.dequeueReusableCellWithIdentifier(armPointCellIdentifier) as! AircraftTableCell
Hope it works! Another solution is to set default values to your cell labels before give them the input of your array.
If anybody stumbles upon that issue. If your ViewController (that has TableView) inside it is a UITabBarController and you are having this issue, there is a temp work-around: Embed your ViewController inside NavigationController. This issue happens only when ViewController is embedded in TabBarController. Like on this picture.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.