我为UISearchBar
实施了UIViewController
并添加了所有必要的代理以使其正常运行,问题是UISearchBar
有时会变得无法响应无论我在iPhone中使用什么磁带键盘都没有显示在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];
}
}