Skip to content

Commit ba82e74

Browse files
committedOct 23, 2015
Delay to create toVC.areaRectInSuperview property, handle it in animation controller.
1 parent 1414a07 commit ba82e74

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed
 

‎Classes/SDENavigationControllerDelegate.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ class SDENavigationControllerDelegate: NSObject, UINavigationControllerDelegate
2020

2121
animationController = SDEPushAndPopAnimationController(operation: operation)
2222
if operation == .Push{
23-
if let fromCollectionVC = fromVC as? UICollectionViewController, let toCollectionVC = toVC as? UICollectionViewController{
24-
let layoutAttributes = fromCollectionVC.collectionView?.layoutAttributesForItemAtIndexPath(fromCollectionVC.selectedIndexPath)
25-
let areaRect = fromCollectionVC.collectionView!.convertRect(layoutAttributes!.frame, toView: fromCollectionVC.collectionView?.superview)
26-
toCollectionVC.areaRectInSuperview = areaRect
23+
if let toCollectionVC = toVC as? UICollectionViewController{
2724
interactionController = SDEPopPinchInteractionController(toVC: toCollectionVC, holder: self)
2825
}
2926
}

‎Classes/SDEPushAndPopAnimationController.swift

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class SDEPushAndPopAnimationController: NSObject, UIViewControllerAnimatedTransi
4747
let selectedCell = fromVC?.collectionView?.cellForItemAtIndexPath(fromVC!.selectedIndexPath)
4848
selectedCell?.hidden = true
4949

50+
let layoutAttributes = fromVC!.collectionView?.layoutAttributesForItemAtIndexPath(fromVC!.selectedIndexPath)
51+
let areaRect = fromVC!.collectionView?.convertRect(layoutAttributes!.frame, toView: fromVC!.collectionView?.superview)
52+
toVC!.areaRectInSuperview = areaRect!
53+
5054
//key code, the most important code here. without this line, you can't get visibleCells from UICollectionView.
5155
//And, there are other ways, Just make view redraw.
5256
toVC?.view.layoutIfNeeded()

0 commit comments

Comments
 (0)
Please sign in to comment.