Auto scrolling to a cell with a specific value

后端 未结 4 1641
盖世英雄少女心
盖世英雄少女心 2020-12-14 09:06

I have a list of numbers in a table view like this.

\"enter

As you can see th

4条回答
  •  太阳男子
    2020-12-14 09:32

    Swift 3.0

     let indexPath = NSIndexPath(forRow: 5, inSection: 0)
     tableView.scrollToRow(at: indexPath, at: .top, animated: true)
    

    Swift 4.0

    let lastRowIndex = self.tblRequestStatus!.numberOfRows(inSection: 0) - 1
    let pathToLastRow = IndexPath.init(row: lastRowIndex, section: 0)
    tableView.scrollToRow(at: pathToLastRow, at: .none, animated: false)
    

提交回复
热议问题