lkzhao / ElasticTransition

A UIKit custom transition that simulates an elastic drag. Written in Swift.
MIT License
2.18k stars 177 forks source link

UINavigationController bug #16

Open mitchellporter opened 8 years ago

mitchellporter commented 8 years ago

I'm using a UINavigationController and triggering a modal segue to another view controller. The transition uses the top edge.

There is a bug that happens sometimes where when I go to perform the segue, the navigation controller's view will flicker and jump up behind the view that we are about to present.

I can't say for sure, but I have a feeling that this could be avoided by not altering the navigation controller's view at all, and instead using a snapshot view. I created an interactive transition from scratch earlier today and have been able to avoid this issue completely by creating a snapshot view with UIApplication.sharedApplication().delegate?.window!!.snapshotViewAfterScreenUpdates(false)

I take a snapshot of the window to capture the nav bar, set the actual nav controller view to hidden, animate the snapshot view during the transition, and when the transition animation is done I unhide the real navigation controller view.

Unfortunately I don't have time to fully test this and submit a PR right now but hopefully this might help anyone else who comes across this problem.

mitchellporter commented 8 years ago

I can't say for sure if this would fix this issue with this library, because I did this in my own custom transition after removing this library, but what I'm doing now is taking a snapshot view of the screen (including nav bar), and animating that instead of animating the nav controller's actual view.

If anyone else runs into this problem I would definitely try the snapshot method.