How to scroll to top in IOS7 UITableView?

后端 未结 12 1838
粉色の甜心
粉色の甜心 2020-12-13 00:25

In IOS6 I have the following code to scroll to the top of a UITableView

[tableView setContentOffset:CGPointZero animated:YES];

In IOS7 this

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 00:35

    var indexPath = NSIndexPath(forRow: 0, inSection: 0)
    self.sampleTableView.scrollToRowAtIndexPath(indexPath,
    atScrollPosition: UITableViewScrollPosition.Top, animated: true)
    

    or

    self.sampleTableView.setContentOffset(CGPoint.zero, animated:false)
    

提交回复
热议问题