3

I have two controllers with UITextFields on them. I need a custom transition between them with the keyboard shown, alongside transition.

When I'm using the default push animation, everything is good. But if I return my transition class from animationControllerForOperation, the keyboard is hiding before and showing after the transition.

So, could someone suggest to me a solution or explanation, why the keyboard is hiding with the custom transition? Transition duration = 0.4, I've set [textField becomeFirstResponder] in viewDidLoad.

Here is a video: https://www.youtube.com/watch?v=gs16tMsU4qY

matt
  • 515,959
  • 87
  • 875
  • 1,141
trickster77777
  • 1,198
  • 2
  • 19
  • 30
  • Could you show your transition animation code? Also, is the hide/show really so bad? I barely noticed it, myself. – matt Apr 14 '15 at 16:31
  • I don't see a reason in your example to even use multiple view controllers for what you're trying to accomplish. That can easily be handled by animating the textField itself to change content without moving controllers in and out. Keeping a keyboard open while changing controllers seems confusing IMO. – Mark McCorkle Apr 14 '15 at 16:34

2 Answers2

1

Take a look at UIViewControllerTransitionCoordinator class.

Here is the answer to the similar issue: https://stackoverflow.com/a/21017900

Community
  • 1
  • 1
tar500
  • 171
  • 2
  • 8
  • `animateAlongsideTransition` is performed only for push for some reason, keyboard view completely ignoring my changes of it's frame, when I return my own `UIViewControllerAnimatedTransitioning` from `animationControllerForOperation`. – trickster77777 Apr 15 '15 at 08:42
0

EDIT

Or even an easier way:

implementing the delegate method - (BOOL) textFieldShouldEndEditing: (UITextField*) textFieldof UITextField and returning NO as long as the next VC is not loaded yet...


Perhaps you could try to override - (BOOL) canResignFirstRespondermethod of UITextField to return NO as long as the view of the new view controller is not loaded yet. (by setting a BOOL property for example, that is set to YES when the new view controller's view is loaded). like:

- (BOOL) canResignFirstResponder {
    return nextVCIsLoaded;
}

perhaps that might prevent the keyboard from being hidden (that seems to happen automatically somewhere within the 'push' operation).

Hope this approach helps.

anneblue
  • 706
  • 4
  • 21