UITableView - scroll to the top

前端 未结 30 3058
南方客
南方客 2020-11-28 17:22

In my table view I have to scroll to the top. But I cannot guarantee that the first object is going to be section 0, row 0. May be that my table view will start from section

30条回答
  •  生来不讨喜
    2020-11-28 18:00

    Swift 3

    tableView.setContentOffset(CGPoint.zero, animated: true)
    

    if tableView.setContentOffset don't work.

    Use:

    tableView.beginUpdates()
    tableView.setContentOffset(CGPoint.zero, animated: true)
    tableView.endUpdates()
    

提交回复
热议问题