iStornZ
iStornZ

Reputation: 858

Keyboard dismiss animation inside an UIAlertView

I have a problem with my iOS Application. Indeed, I have implanted an UIAlertView with an UITextField inside :

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message"
                                                            message:@"message"
                                                           delegate:self
                                                  cancelButtonTitle:@"Done"
                                                  otherButtonTitles:nil];
            alert.alertViewStyle = UIAlertViewStylePlainTextInput;
            UITextField *textField = [alert textFieldAtIndex:0];
            assert(textField);
            textField.keyboardType = UIKeyboardTypeDecimalPad;
            [alert show];

When I touch the "Done" button, there are no dismiss animation for the keyboard, it's not fluid... So I want to add an animation when the user touch the done button :)

Thanks in advance !

Upvotes: 0

Views: 186

Answers (1)

Dklionsk
Dklionsk

Reputation: 203

If your deployment target is iOS 8, you can work around this by using UIAlertController:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title"
                                                               message:@"Message"
                                                        preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.keyboardType = UIKeyboardTypeDecimalPad;
}];
[alert addAction:[UIAlertAction actionWithTitle:@"Done" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];

Upvotes: 2

Related Questions