UISearchBar
has a delegate much like the one for UITextField
. Implement the delegate's searchBar:shouldChangeTextInRange:replacementText:
method. Return YES
or NO
as needed. If you return NO
, the text won't be entered.
- (BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
// check the resulting text. Return NO if not allowed
}