Keyboard not animating - iphone

In a Modal view controller, I'm trying to display a standard keyboard. But It's not animating. In this view, I dismiss and invoke the keyboard. But when I invoked it, there is no animation and It's just appear. (and when I dismiss the keyboard, it just slides down normally).
Any idea, why is this happening ?

Related

Custom inputView not animating correctly during modal presentation

I start by presenting a viewController modally, using the default animation where the view appears from bottom to top. In viewWillAppear, I give first responder to a text field that has a custom keyboard as its inputView. When the view animates for modal presentation, this custom keyboard appears instantly and the rest of the view animates behind it from bottom to top. When I use the default keyboard, it animates correctly with the rest of the view.
How can I get the custom keyboard view to animate while the main view is animating?
Try making your UITextField the first responder inside viewDidAppear instead of viewWillAppear.

How to get the animation right: inputView from a UINavigationController's nav bar?

I have a custom UIControl subclass with a UIPickerView as inputView. When the control is tapped, it calls becomeFirstResponder and the picker view automatically slides up from the bottom of the screen, like the system keyboard. This is working great!
The problem is that I am using the custom control as the titleView of a UINavigationItem. It functions properly, but if the view controller is popped off the navigation controller stack while the picker view is visible, the animation is wonky.
What I want to happen:
everything is pushed off screen to the right at the same time
What actually happens:
first, the background view and navigation bar slide off screen, the picker remains in place
then, after they are gone, the picker slides off to the right also
When I use the custom control inside the view controller's main view, it animates away just like the standard keyboard. So it seems as though this is a function of "coming from" the navigation bar, which is animated separately from the views inside.
How can I fix this, so that the inputView slides out with the rest of the content?
Turns out this can be fixed by calling endEditing: on the UINavigationController's view. In other words, within a view controller:
[self.navigationController.view endEditing:YES];
This causes the input view to slide down while the rest of the view slides off to the right. Not exactly the same as the system keyboard, but not obviously weird.

How do I dismiss a Modal View Controller Form Sheet in Landscape on iPad containing a UITextView?

I have a Modal View Controller presented as a Form Sheet in Landscape on an iPad. When I dismiss the view, the view jumps to a different location, as in this thread:
A modal VC with a keyboard on landscape changes location when dismissed:
Modal View Controller with keyboard on landscape iPad changes location when dismissed
The response to that thread is to call resignFirstResponder, however, you are not allowed to dismiss keyboards when using a Form or Page Sheet:
Modal Dialog Does Not Dismiss Keyboard
Has any one else had this problem? Is there a way to either force the keyboard to be dismissed or force the view into a nice position when it's being animated away?
Cheers,
Nick.
The keyboard will be removed only after the modal form is dismissed. Apple has the idea that if you are using modal form, then you'll need the keyboard for multiple fields therefore it shouldn't be removed.

UIModalView Dismisses stranger when keyboard is active

I'm having a strange issue with my modal view. The modal view asks for some user input so the keyboard pops on. When I click the cancel button to dismiss while the keyboard is still active they both dismiss in an animated fashion but the modal jerks to the right first, very strange. What would be my best course of action here? Would it be to disable my cancel modal button when the keyboard is active? If so how do I go about detecting the presents of the keyboard?
Thanks!
You can detect the presence of keyboard using NSNotification Class. Hope this helps

Keyboard Animation Issues When Calling becomeFirstResponder within a Modal View Controller

I've been having some issues with calling -becomeFirstResponder on a UITextField contained with a view controller that is presented modally. I call this method in the modal view controller's -viewDidLoad method so that the keyboard is immediately displayed. What I expected is for both the keyboard and the modal view controller to animate from up the bottom of the screen at the same time. However, what I'm observing is the following:
There is a ~0.2 second UI lag between clicking the button that calls the -presentModalViewController:animated: method on the parent view controller and when the child view controller begins to animate modally.
The keyboard is immediately presented with absolutely no animation as soon as the modal view controller's animation begins.
Once the modal view controller's animation is complete, everything else seems to operate smoothly.
Dismissing the modal view controller results in it being smoothly animated off screen (along with the keyboard, coincidentally).
Clicking the button that presents the modal view controller any time after the first time results in the same pattern except that there is no ~0.2 second UI lag.
It's as if the keyboard's animation and the modal view controller's animation are both competing for some lower-level Core Animation resource at the same time, but I don't see why this should be happening. What further seems to corroborate this hunch is if I don't ask the UITextField to become the first responder (i.e., if I don't ask the keyboard to present itself), then there is absolutely no UI lag, and the modal view controller animates instantly.
Interestingly, if I do something like [self.textField performSelector:#selector(becomeFirstResponder) withObject:nil afterDelay:0.0001]; then the animation of the keyboard happens nearly at the same time as the modal view controller's animation -- it's extremely difficult to tell that they aren't both being animated at the exact same time when running on the iPhone Simulator. However, when running on an actual device, it's easily noticeable that the keyboard doesn't appear until after the modal view controller is presented. Importantly, though, there's no more UI lag.
Has anyone experienced anything similar to this?
I believe you're having problems because you're effectively stacking animations. The keyboard view is contained by the modal view. The keyboard view is trying to animate its slide in transition within the context of a view which is itself animating a slide in transition. The keyboard animation is trying to hit a moving target.
The pause is most likely the run time of the keyboard transition animation. I am fairly certain the the keyboard animation seizes priority from other animations so that it can drive the rearrangement of the UI e.g. scrolling a table so that the keyboard does not overlay the edited table row. In any case, the keyboard animation occurs within the context of the superview. This is especially true in the case of modal view.
So, the keyboard view animates itself sliding in but because the superview is not actually visible yet, you see nothing. When the superview does slide in, the keyboard is already present because its animation was completed before the superview started its animation.
In short, I don't think you can actual accomplish what you want to do. Instead, I think you will have to animate the modal view transition first, then run the keyboard animation or you will have to accept having the keyboard immediately visible.
I think that Cirrostratus' suggest above is a good one. Use an image of the keyboard that will slide in with the modal view and then immediately swap it out with the real keyboard.
The delayed keyboard animation bothered me as well. viewDidLayoutSubviews was the magical method I was looking for. Placing the becomeFirstResponder call there makes the keyboard slide up in time with the modal.
https://stackoverflow.com/a/19517739/3618864
Try moving your code that sends becomeFirstResponder out of viewDidLoad and into viewWillAppear. I think it is starting too early, you want the keyboard animation to happen when the view appearing animation happens.
Are you saying that you are seeing lag on the Simulator but not on the device? If that's the case you might be seeing a lag due to your computer taking it's time loading everything into memory. When loading up the Simulator the first time it's not just running the code natively, it's probably loading all manner of runtime and debugging libraries. Once loaded into memory the system is probably rather fast. If you are experiancing lag on the Simulator maybe some more RAM in your dev machine might help. If your machine is a few years old you might think about going for something new.
This is what I did to make the keyboard appear to animate exactly the same time as a modalviewcontroller:
In the (init) method of the view being presented modally, I created the UITextField and made it the first responder. Then when I present the modal view controller with animation they both appear at the same time.