我的 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/