forked from weiran/Hackers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:weiran/Hackers
# Conflicts: # Hackers.xcodeproj/project.pbxproj # Podfile # Podfile.lock # Pods/Manifest.lock # Pods/Pods.xcodeproj/project.pbxproj # Pods/Target Support Files/Pods-Hackers/Pods-Hackers-resources.sh # Pods/Target Support Files/Pods-Hackers/Pods-Hackers.debug.xcconfig # Pods/Target Support Files/Pods-Hackers/Pods-Hackers.release.xcconfig # Pods/Target Support Files/libHN/libHN.xcconfig
- Loading branch information
Showing
5 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
Client/UIViewControllerSmoothlyDeselectCellExtension.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// UIViewControllerSmoothlyDeselectCellExtension.swift | ||
// Hackers | ||
// | ||
// Created by Weiran Zhang on 08/06/2016. | ||
// Copyright © 2016 Glass Umbrella. All rights reserved. | ||
// | ||
|
||
extension UIViewController { | ||
func rz_smoothlyDeselectRows(tableView tableView: UITableView?) { | ||
// Get the initially selected index paths, if any | ||
let selectedIndexPaths = tableView?.indexPathsForSelectedRows ?? [] | ||
|
||
// Grab the transition coordinator responsible for the current transition | ||
if let coordinator = transitionCoordinator() { | ||
// Animate alongside the master view controller's view | ||
coordinator.animateAlongsideTransitionInView(parentViewController?.view, animation: { context in | ||
// Deselect the cells, with animations enabled if this is an animated transition | ||
selectedIndexPaths.forEach { | ||
tableView?.deselectRowAtIndexPath($0, animated: context.isAnimated()) | ||
} | ||
}, completion: { context in | ||
// If the transition was cancel, reselect the rows that were selected before, | ||
// so they are still selected the next time the same animation is triggered | ||
if context.isCancelled() { | ||
selectedIndexPaths.forEach { | ||
tableView?.selectRowAtIndexPath($0, animated: false, scrollPosition: .None) | ||
} | ||
} | ||
}) | ||
} | ||
else { // If this isn't a transition coordinator, just deselect the rows without animating | ||
selectedIndexPaths.forEach { | ||
tableView?.deselectRowAtIndexPath($0, animated: false) | ||
} | ||
} | ||
} | ||
} |
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
8 changes: 0 additions & 8 deletions
8
Pods/Target Support Files/Pods-Hackers/Pods-Hackers.debug.xcconfig
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
Pods/Target Support Files/Pods-Hackers/Pods-Hackers.release.xcconfig
This file was deleted.
Oops, something went wrong.