ios - UIAlertView 中的键盘关闭动画

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

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

提前致谢!

最佳答案

如果您的部署目标是 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];

关于ios - UIAlertView 中的键盘关闭动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31230238/

相关文章:

ios - iOS 中的 UITextField 允许单个数字

ios - 使用 UICollectionView 页脚中的对象

ios - 限制删除 UITextField

objective-c - 刷新 mkannotation 属性和刷新注释

iOS:在自定义 UITableViewCell 中更改 contentView backgroundColor on touchDown

ios - UITextField 不可编辑且不显示键盘

ios - react native : how to put element to the right in parent view

iOS 6 UIActivityViewController - 如何用本地语言呈现共享操作表?

ios - 在 iOS 上流式传输 RTSP 时接收 "End of file"

ios - 我如何为某个文本字段创建一个函数?