让 UISearchBar 支持空搜索,当没有输入的时候,search 按钮一样可以点击
//让 UISearchBar 支持空搜索,当没有输入的时候,search 按钮一样可以点击
- (void)searchBarTextDidBeginEditing:(UISearchBar *) searchBar
{
UITextField *searchBarTextField = nil;
NSArray *views = ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0) ? searchBar.subviews : [[searchBar.subviews objectAtIndex:0] subviews];
for (UIView *subview in views)
{
if ([subview isKindOfClass:[UITextField class]])
{
searchBarTextField = (UITextField *)subview;
break;
}
}
searchBarTextField.enablesReturnKeyAutomatically = NO;
}
posted on 2016-11-21 15:17 yucaijiang 阅读(797) 评论(0) 编辑 收藏 举报