Skip to content

Instantly share code, notes, and snippets.

@haraldmartin
Forked from henrik/SearchBarStyler.h
Created June 12, 2010 20:50
Show Gist options
  • Save haraldmartin/436063 to your computer and use it in GitHub Desktop.
Save haraldmartin/436063 to your computer and use it in GitHub Desktop.
// By Henrik Nyh <http://henrik.nyh.se> 2010-06-12 under the MIT license.
#import <Foundation/Foundation.h>
@interface SearchBarStyler : NSObject {
}
+(void)enableReturnKeyWithNoText:(UISearchBar *)searchBar;
@end
#import "SearchBarStyler.h"
@implementation SearchBarStyler
+(void)enableReturnKeyWithNoText:(UISearchBar *)searchBar {
// Really a UISearchBarTextField, but that header is private.
UITextField *searchField = nil;
for (UIView *subview in searchBar.subviews) {
if ([subview isKindOfClass:[UITextField class]]) {
searchField = (UITextField *)subview;
break;
}
}
if (searchField) {
searchField.enablesReturnKeyAutomatically = NO;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment