Created
April 8, 2015 02:05
-
-
Save guarani/65ade8d7fde7184d6f05 to your computer and use it in GitHub Desktop.
A UITableView scrolls to whole UITableViewCells
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { | |
println("scrollViewWillEndDragging") | |
println("targetContentOffset: \(targetContentOffset.memory.y)") | |
var targetContentOffsetCorrected: CGPoint = targetContentOffset.memory | |
targetContentOffsetCorrected.y += contentInsetY | |
println("targetContentOffsetCorrected: \(targetContentOffsetCorrected.y)") | |
let targetCellIndexPath = self.tableView.indexPathForRowAtPoint(targetContentOffsetCorrected) | |
println("targetCellIndexPath row: \(targetCellIndexPath?.row)") | |
let targetCellRect = self.tableView.rectForRowAtIndexPath(targetCellIndexPath!) | |
println("targetCellRect: \(targetCellRect)") | |
var targetCellYCenter = targetCellRect.origin.y | |
println("targetCellYCenter: \(targetCellYCenter)") | |
// let isJumpingDown = (targetContentOffsetCorrected.y % cellHeight) > (cellHeight / 2) | |
// | |
// if isJumpingDown == false { | |
// targetCellYCenter += cellHeight | |
// } | |
targetContentOffset.memory.y = targetCellYCenter - contentInsetY | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment