gpt4 book ai didi

ios - 在键盘上方添加 UITextField

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

我找到了这个 link如何在键盘上方创建工具栏。但是我不使用任何需要点击和显示键盘的文本字段。我的想法是按下“发表评论”按钮,然后会出现带有文本字段的键盘。

所以在我附加的链接中,他们似乎使用了与您交互的文本字段的 inputAccessoryView。但就我而言,我没有任何文本字段。

所以首先我需要在没有文本字段的情况下切换键盘,然后显示带有文本字段的键盘,例如键盘上方的栏。我怎样才能做到?

最佳答案

您好,您需要将 UITextfield 放在 View 之外,像这样:

enter image description here

ViewController.h

@property (strong, nonatomic) IBOutlet UITextField *_myTextField;

ViewController.m

UITextField *t = [UITextField new];
[self.view addSubview:t];
[t becomeFirstResponder];
t.inputAccessoryView = _myTextField;

查看结果: enter image description here

关于ios - 在键盘上方添加 UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31050351/

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