WorldDownTown / ZoomTransitioning

ZoomTransitioning provides a custom transition with image zooming animation and swiping the screen edge.
MIT License
671 stars 54 forks source link

Device orientation bug #18

Open felixolivares opened 7 years ago

felixolivares commented 7 years ago

Hi there, I've noticed that there is bug when device orientation comes into place. To reproduce the error select an image from the main view, it takes you to destination controller, then change device orientation and go back, the collection view stays in the previous orientation and do not updates. Could you advice a solution for this problem ?

acushway commented 5 years ago

I'm seeing this problem as well.

acushway commented 5 years ago

Not sure how good the solution is, but I fixed this for myself by changing ZoomTransitioning.swift

In animateTransitionForPop under the line that sets containerView:

let containerView: UIView = transitionContext.containerView // under this line

sourceView.frame = containerView.frame

The issue seems to be that sourceView still has its old frame. Setting its frame to be equal to containerView fixed the issue for me.

I also had to update my ZoomTransitionSourceDelegate for the pop case:

I needed to add something like:

func transitionSourceImageViewFrame(forward: Bool) -> CGRect { if !forward { UIView.performWithoutAnimation { view.setNeedsLayout() view.layoutIfNeeded() } } return transitionView.convert(transitionView.bounds, to view) }

The key was that the view needed to be laid out again to get things in the correct position for animating back to (in the case that the device had been rotated).