解决方法
幸运的是,我刚刚正在研究正是这样做的代码.这有点像黑客,但你可以找到嵌入在UISearchBar中的UITextField,然后自动关闭enableReturnKey:
UITextField *searchBarTextField = nil; for (UIView *subview in searchBar.subviews) { if ([subview isKindOfClass:[UITextField class]]) { searchBarTextField = (UITextField *)subview; break; } } searchBarTextField.enablesReturnKeyAutomatically = NO;