Auto scrolling to a cell with a specific value

后端 未结 4 1642
盖世英雄少女心
盖世英雄少女心 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:52

    You can use find the index of the item(which will be its row), and then scroll to that index.
    find function returns the index of a particular element in the array.

    if let index = find(items, groupNoToScroll)
    {
        let indexPath = NSIndexPath(forRow: index, inSection: 0)
        tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Top, animated: true)
    }
    

提交回复
热议问题