Add cancel button on searchbar and some possible customization code as comments

This commit is contained in:
Gautier Pelloux-Prayer 2014-10-09 09:30:29 +02:00
parent ae5a5eb57c
commit e678fe584e
2 changed files with 15 additions and 1 deletions

View file

@ -110,7 +110,7 @@
<action selector="onBackClick:" destination="-1" eventType="touchUpInside" id="89"/>
</connections>
</button>
<searchBar contentMode="redraw" id="5jE-oF-d45" userLabel="searchBar">
<searchBar contentMode="redraw" showsCancelButton="YES" id="5jE-oF-d45" userLabel="searchBar">
<rect key="frame" x="0.0" y="44" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textInputTraits key="textInputTraits"/>

View file

@ -151,6 +151,11 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// cannot change search bar icon nor text font from the interface builder...
// [_searchBar setImage:[UIImage imageNamed:@"contact_search.png" ] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
// UITextField *searchText = [_searchBar valueForKey:@"_searchField"];
// [searchText setFont:[UIFont fontWithName:@"CustomFont" size:12]];
BOOL use_system = [[LinphoneManager instance] lpConfigBoolForKey:@"use_system_contacts"];
if( use_system && !self.sysViewController){// use system contacts
ABPeoplePickerNavigationController* picker = [[ABPeoplePickerNavigationController alloc] init];
@ -305,6 +310,12 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[self searchBar:searchBar textDidChange:nil];
[searchBar resignFirstResponder];
[searchBar setText:nil];
}
#pragma mark - ABPeoplePickerDelegate
-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
@ -338,6 +349,9 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
// set searchbar text in uppercase here
// searchBar.text = [searchText uppercaseString];
[ContactSelection setNameOrEmailFilter:searchText];
[tableController loadData];
}