iphoneobjective-cioscocoa-touchresignfirstresponder

resignFirstResponder on UITextView - slowing down the disappearance of the keyboard


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:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // 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.


Solution

  • Simple, I think:

    - (void)btnTestClicked {
            [UIView animateWithDuration:2.0 animations:^(void){
                [tmpText resignFirstResponder];
            } completion:^(BOOL finished) {
                  //Do something
            }];    
        }