ios - UISearchBar 返回类型

标签 ios return uisearchbar

UISearchBar 是第一响应者时,如何更改键盘的 RETURN 类型?例如我想用 DONE 而不是 SEARCH。我无法从我通常在 UITextField 上执行的 XIB 属性中选择它。

最佳答案

没有直接访问,因此您需要找到搜索栏 UITextField 并更改它的键盘。

for (UIView *subview in self.searchBar.subviews)
{
    for (UIView *subSubview in subview.subviews)
    {
        if ([subSubview conformsToProtocol:@protocol(UITextInputTraits)])
        {
            UITextField *textField = (UITextField *)subSubview;
            [textField setKeyboardAppearance: UIKeyboardAppearanceAlert];
            textField.returnKeyType = UIReturnKeyDone;
            break;
        }
    }
}

关于ios - UISearchBar 返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23429102/

相关文章:

java - Apple MDM 供应商 CSR 签名

ios - NSInteger 计数 4 次?

Excel的查找功能;值的异常(exception)

javascript - javascript函数中显式和隐式返回之间有什么区别?

excel - 如何从 VBA 函数返回结果

ios - 如何以编程方式将搜索栏放在导航栏中? - swift

iphone - 在 UISearchbar 中使用书签按钮

objective-c - 将 HTML 文件添加到 SQLite 数据库

javascript - 移动webkit内存消耗

ios - Xcode 中的色调是什么?