UITableView page size when paging enabled

后端 未结 5 1684
攒了一身酷
攒了一身酷 2021-01-31 12:10

I\'m facing with a simple but tedious problem. What I\'m trying to do is make an UITableView to page like an UIScrollView but enabling paging doesn\'t help me so much because I

5条回答
  •  时光说笑
    2021-01-31 12:48

    And in Swift...

    func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        if !decelerate {
            self.scrollViewDidEndDecelerating(scrollView)
        }
    }
    
    func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
        if let indexPathToScrollTo: NSIndexPath = self.tableView.indexPathForRowAtPoint(CGPointMake(self.tableView.contentOffset.x, self.tableView.contentOffset.y+tableView.rowHeight/2)) {
            self.tableView.scrollToRowAtIndexPath(indexPathToScrollTo, atScrollPosition: UITableViewScrollPosition.Top, animated: true)
        }
    }
    

提交回复
热议问题