2
A
回答
3
你可以改变你的UISearchBar对象的keyboardType
财产。但是,没有办法直接更改returnKeyType
。您可能能够过滤并手动更改它。检查UISearchBar的文档并查看是否可以找到returnKeyType
,因为这正是您正在寻找的。
2
我做到这样说:
// -- Basic UISearchBar setup.
self.theSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,320,38)];
[self.theSearchBar setDelegate:self];
[self.view addSubview:self.theSearchBar];
// -- Customize the returnKeyType of the search bar's nested UITextField.
UITextField *searchBarTextField = [[self.theSearchBar subviews] objectAtIndex:1];
searchBarTextField.returnKeyType = UIReturnKeyGo;
希望这是有帮助的。这种方法(即通过索引获取子视图)可能会在未来中断,但现在它可以正常工作。
-1
不要依赖它作为第二个子视图,使用isKindOfClass:方法来检查。这将是更多的iOS更新证明。
for (UIView *subview in self.theSearchBar.subviews) {
if ([subview isKindOfClass:[UITextField class]]) {
[(UITextField *)subview setReturnKeyType:UIReturnKeyGo];
break;
}
}
0
for (UIView *view in _searchBar.subviews){
if ([view isKindOfClass:[UITextField class] ]) {
UITextField *searchTf = (UITextField *)view;
searchTf.returnKeyType = UIReturnKeyDone;
}
}
0
这是工作的iOS 6
UITextField *searchBarTextField = [[searchBarObj subviews] objectAtIndex:1];
searchBarTextField.returnKeyType = UIReturnKeyDefault;
[searchBarTextField setEnablesReturnKeyAutomatically:NO];
这是工作的iOS 7
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;
}
}
}
相关问题
- 1. 的UISearchBar搜索按钮
- 2. UISearchBar - 什么是“搜索结果按钮”?
- 3. 更改UISearchBar搜索按钮上的UITableView数据源点击
- 4. 搜索栏从iphone上的搜索按钮扩展
- 5. 上的取消按钮按下的UISearchBar的 - 在iPhone
- 6. UISearchbar上的取消按钮
- 7. 我如何解雇键盘上关于UISearchBar的键盘上的搜索按钮?
- 8. 可可触摸 - UISearchBar键盘 - 隐藏'搜索'按钮
- 9. 如何禁用/启用UISearchBar键盘的搜索按钮?
- 10. 自定义搜索结果按钮具有的UISearchBar
- 11. Iphone UISearchBar取消按钮故障
- 12. 当字段为空时,为UISearchBar启用“搜索”按钮? (iOS 7)
- 13. 无法隐藏键盘单击搜索按钮在UISearchBar
- 14. 更改UISearchBar /键盘搜索按钮标题
- 15. 使用UISearchBar搜索
- 16. UISearchBar搜索记录
- 17. iPhone - 搜索栏上的自定义按钮?
- 18. 如何启用UI搜索栏上的取消按钮iPhone
- 19. 在按钮上搜索NULL值按下
- 20. 按Uisearchbar x按钮按下
- 21. 搜索时的UISearchBar背景
- 22. Bing搜索框内的搜索按钮
- 23. 搜索键盘中的搜索按钮
- 24. 在UISearchBar上执行搜索NSArray
- 25. Magento上的搜索按钮破解
- 26. 手机上的搜索按钮事件
- 27. 编程键盘上的搜索按钮
- 28. 把搜索框搜索按钮的左侧点击按钮
- 29. 搜索按钮+ gridview
- 30. VB.net搜索按钮
感谢,但不幸的是在搜索栏中没有这个属性.. 。:( – SpaceDog 2010-07-17 02:21:51