Last active
June 10, 2016 03:44
-
-
Save ateliercw/928b24103531c0f100e4972734bbb46b to your computer and use it in GitHub Desktop.
An un-curried deselect function, for comparison with curried_deselect
This file contains hidden or 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
extension UIViewController { | |
func rz_smoothlyDeselectRows(tableView tableView: UITableView?) { | |
let selectedIndexPaths = tableView?.indexPathsForSelectedRows ?? [] | |
if let coordinator = transitionCoordinator() { | |
coordinator.animateAlongsideTransitionInView(parentViewController?.view, animation: { context in | |
selectedIndexPaths.forEach { | |
tableView?.deselectRowAtIndexPath($0, animated: context.isAnimated()) | |
} | |
}, completion: { context in | |
if context.isCancelled() { | |
selectedIndexPaths.forEach { | |
tableView?.selectRowAtIndexPath($0, animated: false, scrollPosition: .None) | |
} | |
} | |
}) | |
} | |
else { | |
selectedIndexPaths.forEach { | |
tableView?.deselectRowAtIndexPath($0, animated: false) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment