Enable search button on keyboard with empty value on UISearchBar
@implementation UISearchBar (UISearchBar_EnableEmptySearch)
- (void)enableEmptySearch {
UITextField *searchBarTextField = nil;
for (UIView *subView in self.subviews){
for (UIView *secondLeveSubView in subView.subviews){
if ([secondLeveSubView isKindOfClass:[UITextField class]])
{
searchBarTextField = (UITextField *)secondLeveSubView;
break;
}
}
}
searchBarTextField.enablesReturnKeyAutomatically = NO;
}
#import <UIKit/UIKit.h>
@interface UISearchBar (UISearchBar_EnableEmptySearch)
- (void)enableEmptySearch;
@end