我实现了一个UISearchBar
to aUIViewController
并添加了所有必要的Delegates以使其正常运行,问题是UISearchBar
有时会变得无响应,并且我在 iPhone Keypad 中录制的任何内容都不会出现在 上UISearchBar
,尤其是当我按下一个新的UIViewController
然后我弹出它时背部。我的代码有什么问题
@interface ViewController : UIViewController <UIAlertViewDelegate, UISearchBarDelegate> {
IBOutlet UISearchBar * SearchBar ;
}
-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:YES];
SearchBar.delegate = self ;
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[self.view endEditing:YES];
if(SearchBar.text.length < 3){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
message:@"Votre recherche doit contenir 3 caractères minimum"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}else{
self.Array = [[NSMutableArray alloc] init];
[self getData];
}
}