我正在尝试复制类似于“消息”的用户界面。我有一个 UIToolbar 固定在 xib View 的底部。在该工具栏上是一个 UITextField。我已将 UITextField 的输入 AccessoryView 设置为 UIToolbar。当我单击 UITextField 时,它会卡入到位,但下方没有键盘,只是空白,就好像键盘被隐藏了一样。当我第二次单击 UITextField 时,它会使用键盘进行动画处理。我试图成为它的代表和其他 SO 帖子中的所有其他建议,但没有成功。
@implementation ChatViewController {
IBOutlet UIToolbar *_keyboardAccessory;
IBOutlet UITextField *_textField;
}
- (void)viewDidLoad {
[super viewDidLoad];
[_textField setInputAccessoryView:_keyboardAccessory];
}
最佳答案
如果您不尝试使工具栏成为文本字段的 inputAccessoryView
,将会更简单。只需在键盘出现时将工具栏设置为动画,在键盘消失时将工具栏设置为动画。
做这个动画你需要知道的一切都记录在“Managing the Keyboard” in the Text, Web, and Editing Programming Guide for iOS中.您还可以在描述该过程的堆栈溢出中找到答案。 here is an answer describing the process step-by-step with all the code.
关于ios - UITextField 作为它自己的 inputAccessoryView 的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18301341/