recruit-mp / RMPZoomTransitionAnimator

A custom zooming transition animation for UIViewController
MIT License
1.71k stars 178 forks source link

call transitionDestinationImageViewFrame after UICollectionView reload data #8

Closed y0unghe closed 9 years ago

y0unghe commented 9 years ago

I have a collection view controller, and it's datasource come from a view controller that push it. Every time I push this collection view controller, it's datasource will get reloaded. I set two breakpoints to cellForItemAtIndexPath and transitionDestinationImageViewFrame. The first function get called is transitionDestinationImageViewFrame and then cellForItemAtIndexPath. When it's in transitionDestinationImageViewFrame, the collection view cell is not init yet, so there is no way the animation will work. So, how to call transitionDestinationImageViewFrame after the collection view controller finished reload data, for example cellForItemAtIndexPath.

mpon commented 9 years ago

Hi @y0unghe

the collection view cell is not init yet, so there is no way the animation will work.

That's right.

So, how to call transitionDestinationImageViewFrame after the collection view controller finished reload data, for example cellForItemAtIndexPath.

I think you can use RMPZoomTransitionDelegate. Please read the following document.

/**
 Delegate handler of viewController which implements transitioning protocol
 */
@protocol RMPZoomTransitionDelegate <NSObject>
@optional

/**
 Notify the end of the forward and backward animations.

 get the original UIImageView and hide it, while the copy is being animated.
 And when the animation is done, the original could be shown.
 That will prevent the original views to be shown while animating.
 */
- (void)zoomTransitionAnimator:(RMPZoomTransitionAnimator *)animator
         didCompleteTransition:(BOOL)didComplete
      animatingSourceImageView:(UIImageView *)imageView;

@end