gpt4 book ai didi

objective-c - UIPickerView : Keyboard not hiding

转载 作者:行者123 更新时间:2023-11-28 22:57:07 25 4
gpt4 key购买 nike

我有3个UITexfield,用户可以填写前两个,但最后一个是类别字段,点击时显示一个UIPickerView。

到目前为止我已经设法做到的是:

  • 用户点击类别文本字段 -> 出现选择器 View
  • 然后用户点击另一个文本框 -> 选择器 View 消失,键盘出现

但是我想在用户再次单击类别文本字段并显示选择器 View 时隐藏键盘。

这是我目前所拥有的:

- (void)textFieldDidBeginEditing:(UITextField *)textField {
if(textField == categoryTextField){
[categoryTextField resignFirstResponder];
[UIView beginAnimations:@"picker" context:nil];
[UIView setAnimationDuration:0.3];
pickerView.transform = CGAffineTransformMakeTranslation(0,-236);
[UIView commitAnimations];
}else{
[UIView beginAnimations:@"picker" context:nil];
[UIView setAnimationDuration:0.3];
pickerView.transform = CGAffineTransformMakeTranslation(0,236);
[UIView commitAnimations];
}
}

但它不起作用。有没有想过为什么?

最佳答案

你太难了。将选择器 View 设置为文本字段的输入 View ,操作系统将为您处理动画。当每个字段成为第一响应者时,将显示适当的输入 View (文本的默认键盘,第三个的选择器)。您不需要自己制作任何动画。

关于objective-c - UIPickerView : Keyboard not hiding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10563216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com