网上都是这一类代码[tableview setContentOffset:CGPointMake(0,0) animated:NO];
应该是我有加了navigationItem,这个方法会遮住第一个item,后来找到了这个方法
let section = self.query.numberOfSections() if(section > 0 ){ let row = self.query.numberOfRowsInSection(0) if (row > 0){ let indexPath = NSIndexPath(forRow: 0,inSection: 0) self.query.scrollToRowAtIndexPath(indexPath,atScrollPosition: UITableViewScrollPosition.Top,animated: true) } }然后搞定了 原文链接:https://www.f2er.com/swift/325973.html