我的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];
当我触摸“完成”按钮时,键盘没有消除动画,它不流畅......所以我想在用户触摸完成按钮时添加动画:)
提前致谢!
答案 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];