UITableView - scroll to the top

前端 未结 30 2962
南方客
南方客 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:51

    I had to add the multiply by -1 * to the sum of the status bar and the navigation bar, because it was going that height off the screen,

    self.tableView.setContentOffset(CGPointMake(0 , -1 * 
      (self.navigationController!.navigationBar.height +  
      UIApplication.sharedApplication().statusBarFrame.height) ), animated:true)
    

提交回复
热议问题