Made the search bar delegate OK, and hide/show the cancel button on demand

This commit is contained in:
Guillaume BIENKOWSKI 2014-10-20 11:16:35 +02:00
parent 3256ee4388
commit a5584c2794
2 changed files with 11 additions and 2 deletions

View file

@ -75,7 +75,7 @@ typedef enum _ContactSelectionMode {
@end
@interface ContactsViewController : UIViewController<UICompositeViewDelegate,ABPeoplePickerNavigationControllerDelegate> {
@interface ContactsViewController : UIViewController<UICompositeViewDelegate,ABPeoplePickerNavigationControllerDelegate,UISearchBarDelegate> {
BOOL use_systemView;
}
@ -94,5 +94,4 @@ typedef enum _ContactSelectionMode {
- (IBAction)onAddContactClick:(id)event;
- (IBAction)onBackClick:(id)event;
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;
@end

View file

@ -348,6 +348,8 @@ static UICompositeViewDescription *compositeDescription = nil;
return false;
}
#pragma mark - searchBar delegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
// set searchbar text in uppercase here
// searchBar.text = [searchText uppercaseString];
@ -356,6 +358,14 @@ static UICompositeViewDescription *compositeDescription = nil;
[tableController loadData];
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar {
[searchBar setShowsCancelButton:FALSE animated:TRUE];
}
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
[searchBar setShowsCancelButton:TRUE animated:TRUE];
}
- (void)viewDidUnload {
[self setToolBar:nil];
[super viewDidUnload];