ios - iPhone:UISearchBar 如何搜索 ""字符串?

标签 ios iphone objective-c ipad uisearchbar

我希望能够搜索其中没有任何字符的字符串。问题是,当 UISearchBar 中没有任何内容时,默认键盘不会显示搜索按钮。

有什么想法吗?

谢谢, 马库斯

最佳答案

幸运的是,我恰好正在编写完全可以执行此操作的代码。这有点 hack,但您可以找到嵌入在 UISearchBar 中的 UITextField,然后关闭 enablesReturnKeyAutomatically:

UITextField *searchBarTextField = nil;
for (UIView *subview in searchBar.subviews)
{
    if ([subview isKindOfClass:[UITextField class]])
    {
        searchBarTextField = (UITextField *)subview;
        break;
    }
}
searchBarTextField.enablesReturnKeyAutomatically = NO;

关于ios - iPhone:UISearchBar 如何搜索 ""字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3846917/

相关文章:

ios - 传入的富推送通知不会显示图像。 swift 4

ios - 在 iOS 中下载文件的内存管理

iPhone NSURL 错误

iphone - 如何在ios中连续调用Web服务

ios - swift:如何在另一个 View Controller 中访问一个变量?

iOS 应用程序登录网站

iphone - 数据: <fault> when return fetch request objects from method

ios - 按谷歌登录按钮时没有任何反应

在选择 'download full message' 之前,Html 电子邮件不会显示在 iPhone 邮件中

objective-c - Xcode 问题 : Quickly jump to a particular selector/class/symbol?