I am having an issue with UITableViewCell. When the table view loads, some of the cell does not have subtitle. I aldy set the style of cell to subtitle. The weird part is when I scroll up and down, the missing parts appear again but some other cells are missing table subtitle. Here is my code for the cellForRowAtIndexPath
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! UITableViewCell
cell.layoutMargins = UIEdgeInsetsZero
cell.preservesSuperviewLayoutMargins = false
let poList = self.PoList[indexPath.row]
if(poList.POShort == "header"){
cell.backgroundColor = SharedClass().coopGroupHeaderColor
let selectedColor = UIView()
selectedColor.backgroundColor = SharedClass().coopGroupHeaderColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.textColor = UIColor.blackColor()
cell.textLabel?.font = UIFont.boldSystemFontOfSize(18.0)
cell.textLabel?.textAlignment = .Left
cell.accessoryType = .None
let t_header = "Program Office"
cell.textLabel?.text = t_header
cell.detailTextLabel?.text = ""
cell.userInteractionEnabled = false;
}
else{
cell.backgroundColor = indexPath.row % 2 == 0 ? UIColor.clearColor() : SharedClass().cellBackGroundColor
let selectedColor = UIView()
selectedColor.backgroundColor = SharedClass().selectedCellColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.font = UIFont.boldSystemFontOfSize(11.0)
cell.textLabel?.textColor = UIColor.blackColor()
if(poList.POShort != "OTHER" && poList.POShort != "invalid" && poList.POShort != "all"){
cell.textLabel?.text = poList.POName + " - " + poList.POShort
}
else{
cell.textLabel?.text = poList.POName
}
let cellValue = "Total number of staff not responded - " + poList.totalUsers
cell.detailTextLabel?.text = cellValue
if(poList.totalUsers == "0"){
cell.userInteractionEnabled = false;
cell.accessoryType = .None
}
else{
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
}
}
return cell
and as a result, this cells missing subtitle will not perform push segue either.
Please help.
Thank you.