UIAlertView 中的键盘关闭动画
Keyboard dismiss animation inside an 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];
当我触摸 "Done" 按钮时,键盘没有关闭动画,它不流畅...所以我想在用户触摸完成按钮时添加一个动画 :)
提前致谢!
如果您的部署目标是 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
和一个 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];
当我触摸 "Done" 按钮时,键盘没有关闭动画,它不流畅...所以我想在用户触摸完成按钮时添加一个动画 :)
提前致谢!
如果您的部署目标是 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];