如何让ios键盘手动出现?

发布于 2024-12-23 05:49:07 字数 160 浏览 2 评论 0原文

我有一个自定义视图,它将充当文本字段,另一个自定义视图帽将充当其键盘。我本来打算实现 uikeyinput 协议,但由于它是自定义键盘,它无法通过 uikeyinput 向其委托发送消息,所以我想我也可以制作一个自定义协议。 将文本字段设为第一响应者后,如何对键盘进行编程,使其在有人单击文本字段时出现?

I have a custom view which will act as a text field and another custom view hat acts as its keyboard. I was planning on implementing uikeyinput protocol, but since its a custom keyboard, it can't send messages to its delegate through uikeyinput, so I thought I might as well make a custom protocol as well.
After making the text field first responder, how do I program the keyboard to appear when someone clicks the text field?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

讽刺将军 2024-12-30 05:49:07

当文本字段成为第一响应者时,它会自动调出键盘。要使键盘出现,只需发送 [textFieldBecomeFirstResponder]

When a text field becomes first responder, it'll automatically bring up the keyboard. To make the keyboard come up, just send [textField becomeFirstResponder].

我要还你自由 2024-12-30 05:49:07

在自定义视图类标头中声明属性 inputView

@property (nonatomic, readonly) MyCustomKeyboardView *inputView;

不要合成它。相反,在自定义视图类中显式实现 getter 以返回自定义键盘视图。一旦您的视图成为第一响应者,Cocoa 就会自动读取此属性以检查您的视图是否需要自定义键盘。它甚至可以为键盘设置动画。

请参阅 UIResponder

Declare the property inputView in your custom view class header:

@property (nonatomic, readonly) MyCustomKeyboardView *inputView;

Don't synthesize it. Instead, explicitly implement the getter in your custom view class to return your custom keyboard view. Once your view becomes first responder Cocoa automatically reads this property to check if your view needs a custom keyboard. It even animates the keyboard in.

See the documentation for UIResponder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文