0

Swift に PFTableViewCells を持つ PFTableViewController があります。

各 TableViewCell (画面サイズの 80% の高さ) には、ボタンがあります。ユーザーがボタンを選択すると、次の TableViewCell に自動スクロールされるようにしたいと思います。

どうすればそれを作ることができますか?

どうもありがとう

4

1 に答える 1

0

indexPath を決定し、次の indexPath までスクロールするだけです。この例では、セクションのないフラット テーブルを想定しています。

func buttonTapped(sender: UIButton) {
    let point = sender.convertPoint(CGPointZero, toView:tableView)
    let indexPath = tableView.indexPathForRowAtPoint(point)!
    // check for last item in table
    if indexPath.row < tableView.numberOfRowsInSection(indexPath.section) {
        let newIndexPath = NSIndexPath(forRow:indexPath.row + 1 inSection:indexPath.section)
        tableView.scrollToRowAtIndexPath(
             newIndexPath, atScrollPosition:.Top, animated: true)
    }

}
于 2015-07-25T10:51:24.190 に答える