使用 iPhone 多点触控键盘搜索按钮

发布于 2024-08-30 01:23:54 字数 121 浏览 0 评论 0原文

我的视图上有一个常规文本字段,我想使用 iPhone 键盘上的搜索按钮。对于我的一生,我不知道如何做到这一点。似乎没有任何我可以连接的、与键盘上的搜索按钮特别相关的事件。我用谷歌搜索了一下,但也没有找到与这个主题相关的任何内容。

I have a regular text field on a view and I'd like to make use of the search button on the iPhones keyboard. For the life of me, I can't figure out how to do this. There doesn't seem to be any event exposed that I can wire up that specifically relates to the search button on the keyboard. I've googled around, but I also haven't found anything related to this subject.

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

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

发布评论

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

评论(1

野稚 2024-09-06 01:23:54

通过设置返回键类型,使键盘显示蓝色的“搜索”按钮。

myTextField.returnKeyType = UIReturnKeySearch;

将文本字段的委托设置为控制器并实现“textFieldShouldReturn:”方法。

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    /* Do some searching here */
    return YES;
}

Make the keyboard display the blue "Search" button by setting the return key type.

myTextField.returnKeyType = UIReturnKeySearch;

Set the delegate of your text field to your controller and implement the 'textFieldShouldReturn:' method.

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    /* Do some searching here */
    return YES;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文