Why does my UITableView “jump” when inserting or removing a row?

后端 未结 10 1200
小蘑菇
小蘑菇 2020-12-05 10:21

(Happy to accept an answer in Swift or Objective-C)

My table view has a few sections, and when a button is pressed, I want to insert a row at the end of section 0.

10条回答
  •  清歌不尽
    2020-12-05 10:35

    for me work, turn off automatic estimate for tableview rows, section, headers and I use heightForRowAt

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            if indexPath.row % 2 == 1 {
                if arrowsVisible {
                    return 20
                }
                return 5
            }
    }
    

提交回复
热议问题