UITableView - scroll to the top

前端 未结 30 3042
南方客
南方客 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 17:57

    For tables that have a contentInset, setting the content offset to CGPointZero will not work. It'll scroll to the content top vs. scrolling to the table top.

    Taking content inset into account produces this instead:

    [tableView setContentOffset:CGPointMake(0, -tableView.contentInset.top) animated:NO];
    

提交回复
热议问题