-1

I am trying to add two custom UITableViewcell in UITableview section but first section is displaying properly and second section custom cell is not displaying. How can I fix this?

Here is my code.

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if section == 0 {
       return itemsTitleArray.count
    } else {
       return approvalsArray.count
    }
}
        
func numberOfSections(in tableView: UITableView) -> Int {
   return sectionArray.count
}
               
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
   return sectionArray[section]
}
            
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {             
 switch indexPath.section {
  case 0:
     //first cell
    let cell = tableView.dequeueReusableCell(withIdentifier:“FirstTableViewCell", for: indexPath) as! FirstTableViewCell
    cell.itemTitleLabel?.text = itemsTitleArray[indexPath.row]            
    cell.backgroundColor = .red
    return cell
    case 1:
    //second cell
    let cell = tableView.dequeueReusableCell(withIdentifier:“SecondTableViewCell", for: indexPath) as! SecondTableViewCell
    cell.approvalStausLabel.text = approvalsArray[indexPath.row]
    cell.backgroundColor = .yellow
    return cell
  default:
    return UITableViewCell()
   }
                
}    
halfer
  • 19,824
  • 17
  • 99
  • 186
IOS Rocks
  • 2,127
  • 2
  • 21
  • 24

1 Answers1

0

The imageView leading to Superveiw contraint was the probelem. After removing the contraint the second section is displaying.

IOS Rocks
  • 2,127
  • 2
  • 21
  • 24