代码如下:
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;
}
}