键盘解除UIAlertView内的动画

时间:2015-07-05 12:16:47

标签: ios objective-c uitextfield uialertview

我的iOS应用程序有问题。实际上,我已经在UIAlertView内植入了一个UITextField

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];

当我触摸“完成”按钮时,键盘没有消除动画,它不流畅......所以我想在用户触摸完成按钮时添加动画:)

提前致谢!

1 个答案:

答案 0 :(得分:2)

如果您的部署目标是iOS 8,则可以使用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];