当 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/