0

I am having this weird issue. when I scroll tableview and update some cell it bounce equivalent to the amount first cell scrolled.

I am having one view controller with tableview in it and based on user select some rows i'm updating only that row using below code

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let index = indexPath.row
    print(index)
    let service = services[indexPath.row]
    if service.isEnabled {
        service.isEnabled = false
    }
    else {
        service.isEnabled = true
    }
    let indexPath = IndexPath(item: index, section: 0)
    serviceTableView.reloadRows(at: [indexPath], with: .fade)
}

this is working fine if I don't scroll the table view but if i scroll table view and select some cell its bounce the entire tableview

Things already tried

  1. Removing all constraints of table view, it still bounce
  2. Removing all config methods from cellForRowAt indexPath
  3. Different simulators

also I am not doing anything in section view.

PS: What I observe is that it only happens when first cell is partially visible/hidden.

gif image added for reference

Iraniya Naynesh
  • 1,125
  • 3
  • 14
  • 26
  • Why do you reload? What about changing the UI part on that method: `if let cell = tableView.cell(forIndexPath:indexPath) as MyCell{//changeUI}`? – Larme Feb 22 '18 at 14:45
  • func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "MusicServiceTableViewCell") as! MusicServiceTableViewCell cell.selectionStyle = .none cell.delegate = self let service = services[indexPath.row] cell.configureCell(withService: service, index: indexPath.row) return cell } – Iraniya Naynesh Feb 22 '18 at 15:13
  • even if I comment all that code and just show static label still its behaving like this – Iraniya Naynesh Feb 22 '18 at 15:14
  • And this is only happening in simulator I run the same code in device 10.3 iPhone 5 its working perfectly. So I'm thinking it must be some simulator issue – Iraniya Naynesh Feb 22 '18 at 15:15
  • Have you implemented `estimatedHeightForRowAt`? – Paulw11 Feb 22 '18 at 16:25
  • yes func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 80 } – Iraniya Naynesh Feb 23 '18 at 04:05

0 Answers0