让UISearchBar支持空搜索

代码如下:

NSArray *views = [[UIDevice currentDevice].systemVersion floatValue] < 7.0?searchBar.subviews:[[searchBar.subviews firstObject] subviews];

for(UIView *subview in views) {

    if([subview isKindOfClass:[UITextField class]]) {

           UITextField *textField = (UITextField*)subview;

           textField.enablesReturnKeyAutomatically = NO;

           break;

      }

}

你可能感兴趣的:(让UISearchBar支持空搜索)