iOS Search bar 输入空字符串也可以搜索

时间:2014-05-26 07:25:46   收藏:0   阅读:310

Search bar delegate

bubuko.com,布布扣
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    UITextField *searchBarTextField = nil;
    for (UIView *mainview in searchBar.subviews) {
        if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
            if ([mainview isKindOfClass:[UITextField class]]) {
                searchBarTextField = (UITextField *)mainview;
                break;
            }
        }
        for (UIView *subview in mainview.subviews) {
            if ([subview isKindOfClass:[UITextField class]]) {
                searchBarTextField = (UITextField *)subview;
                break;
            }
        }
    }
    searchBarTextField.enablesReturnKeyAutomatically = NO;
}
bubuko.com,布布扣

 

iOS Search bar 输入空字符串也可以搜索,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!