Take the 2-minute tour ×

I wonder is there any way to slow down the disappearance of a native keyboard in an iOS app when using resignFirstResponder on a TextView. The keyboard is going down too fast and I want it to go slower. Is that possible?

EDIT: My context is this: I add a new view on top of the current view and because of this, my keyboard disappears momentarily. That's how my code looks:

- (void)viewDidLoad
    [super viewDidLoad];

    UIButton *tmpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [tmpButton setTitle:@"Tap me" forState:UIControlStateNormal];
    [tmpButton sizeToFit];
    [tmpButton addTarget:self action:@selector(btnTestClicked) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:tmpButton];

- (void) btnTestClicked{
    [tmpText resignFirstResponder];

I also have the view hierarchy like that:

    // Override point for customization after application launch.
    self.window.windowLevel = UIWindowLevelStatusBar + 1;
    return YES;

The app is real simple but the keyboards disappears very fast, not like when I don't have any other views.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Simple,I think:

- (void) btnTestClicked{
        [UIView animateWithDuration:2.0 animations:^(void){
            [tmpText resignFirstResponder];
        } completion:^(BOOL finished) {
              //Do something
share|improve this answer
Interestingly enough, it slows down the appearance of the keyboard, not it's disappearance. The keyboard still just fades away, not roll down slowly like it should. Do you know why it's like that? –  SergiusGee Dec 25 '12 at 14:01
I've test, resignFirstResponder mean disappearance. –  iAn Dec 25 '12 at 14:04
I know what it does, but the disappearance isn't slow. Maybe the reason is I have this thing in appDelegate? Check out my new edit, please –  SergiusGee Dec 25 '12 at 14:08
Sorry, I don't know what's the purpose of "self.window.windowLevel = UIWindowLevelStatusBar + 1"; But I delete it, it work OK. –  iAn Dec 25 '12 at 14:27
I also check,self.window.windowLevel just work in range [-1:10]. I still not understand.Sorry,I don't have any new investigation. –  iAn Dec 25 '12 at 15:57
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
    [self.view endEditing:YES];
share|improve this answer
Check out my edit. Where exactly should I put the code? –  SergiusGee Dec 25 '12 at 13:55
put this code in btnTestClicked –  Rajneesh071 Dec 25 '12 at 13:55
I tried and this doesn't work, unfortunately. –  SergiusGee Dec 25 '12 at 13:57
tried [tmpText resignFirstResponder]; insted [self.view endEditing.....] –  Rajneesh071 Dec 25 '12 at 14:56
Sure, I tried everything. The problem is with the self.window.windowLevel = UIWindowLevelStatusBar + 1; –  SergiusGee Dec 25 '12 at 14:57

Your Answer


