0

I have an tableview with array

var scheduledShootsArray = ["a","b","c","e","f","c","e","f"]

my tableview datasources.

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return isScheduledShootSelected ? scheduledShootsArray.count : completedShootsArray.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = segmentTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ShootsTableViewCell
     if isScheduledShootSelected {
        
        cell.fimName.text = scheduledShootsArray[indexPath.row]
     } 
     return cell
   }

enter image description here

its having extra 2 empty cells how to resolve this?

NSP
  • 31
  • 6

1 Answers1

0

This is because although they are not filled with data by default UITableView wil always show separators. You can solve this in a few ways

Solution 1: Add clear footer to your tableview

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    return UIView()
}

Solution 2: Add footer on setup tableview

func setupTableView() {
    // Set delegates etc.
    tableView.tableFooterView = UIView()
}

Solution 3: Remove your separator lines

func setupTableView() {
    // Set delegates etc.
    tableView.separatorStyle = .none
}
Stijnk008
  • 222
  • 3
  • 23