Skip to content

Conversation

@kainosnoema
Copy link

This fixes a keyboard flash bug caused by non-interactive transitions, such as modal presentations. Another way to fix modal transitions whould be to check presentationStyle, but from what I can tell we only need to handle interactive transitions anyway.

[UIViewControllerTransitionCoordinator initiallyInteractive] returns
true only if the transition is both animated and interactive, so it seems like the right thing to check.

@davelyon
Copy link
Contributor

Good catch. I'm not 100% convinced that this will work reliably when dismissing non-interactively (I've seen instances of back buttons causing the keyboard to drop down during the left to view push, specifically the Notes app is really ugly about this).

I'm not sure what the best solution is, however, as the presentationStyle attribute doesn't actually tell you much about how the view is being presented in some cases -- so I think the better solution short term for what you're wanting to accomplish is to check for UIModalPresentationNone to be true. Also, I think the check for animated is still important to keep around for the sake of paranoia. I'd rather not worry about what adding an animation to a non-animated transition stack might do.

Thanks for looking in to this!

@kainosnoema
Copy link
Author

Welp, I was wrong about presentationStyle. It's set to UIModalPresentationNone, even when presenting a view controller using UIModalPresentationCurrentContext (passed to [UIViewController presentViewController:animated:completion:]). No idea why. To explain a bit better, the problem I'm seeing is that calling becomeFirstResponder during that presentation transition causes the keyboard to flash up and down as the new view controller transitions up.

This fix still seems to work really well in the non-interactive back button case you mentioned, so I think it might still be the best solution. Can you think of another scenario where this would cause problems?

`[UIViewControllerTransitionCoordinator initiallyInteractive]` returns
true only if the transition is both animated and interactive.

https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewControllerTransitionCoordinatorContext_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIViewControllerTransitionCoordinatorContext/initiallyInteractive

This fixes bugs caused by non-interactive transitions, some of which
aren't even panning, such as modal presentation transitions. Another
way to fix modal transitions whould be to check `presentationStyle`,
but from what I can tell we only need to handle interactive
transitions anyway.

Signed-off-by: Evan Owen <kainosnoema@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants