如何隐藏/删除联系人选取器上的search栏

我在我的应用程序中添加联系人select器,但是,我不想要searchfunction。

如何隐藏/删除联系人选取器(ABPeoplePickerNavigationController)上的search栏?

static BOOL foundSearchBar = NO; - (void)findSearchBar:(UIView*)parent mark:(NSString*)mark { for( UIView* v in [parent subviews] ) { //if( foundSearchBar ) return; NSLog(@"%@%@",mark,NSStringFromClass([v class])); if( [v isKindOfClass:[UISearchBar class]] ) { [(UISearchBar*)v setTintColor:[UIColor blackColor]]; v.hidden=YES; // foundSearchBar = YES; break; } if( [v isKindOfClass:[UITableView class]] ) { CGRect temp =v.frame; temp.origin.y=temp.origin.y-44; temp.size.height=temp.size.height+44; v.frame=temp; //foundSearchBar = YES; break; } [self findSearchBar:v mark:[mark stringByAppendingString:@"> "]]; } } 

在select器显示如下之后调用上面的方法:

 -(void)showPeoplePickerController { ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init]; picker.peoplePickerDelegate = self; picker.view.autoresizingMask = UIViewAutoresizingFlexibleHeight; // Display only a person's phone, email, and birthdate NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], [NSNumber numberWithInt:kABPersonEmailProperty], [NSNumber numberWithInt:kABPersonBirthdayProperty],[NSNumber numberWithInt:kABPersonAddressProperty],nil]; picker.displayedProperties = displayedItems; // Show the picker [self presentViewController:picker animated:YES completion:nil]; [self findSearchBar:[picker view] mark:@"> "]; [picker release]; } 
 -(void)showAddressBook { ABPeoplePickerNavigationController *addressBook = [[ABPeoplePickerNavigationController alloc] init]; [addressBook setPeoplePickerDelegate:self]; addressBook.delegate = self; addressBook.navigationBar.topItem.title = @"iPhone Contacts"; UIView *view = addressBook.topViewController.view; for (UIView *v in view.subviews) { if ( [v isKindOfClass:[UITableView class]] ) { CGRect temp = v.frame; temp.origin.y = temp.origin.y - 44; temp.size.height = temp.size.height + 44; v.frame = temp; } } [addressBook release]; } - (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if ([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]]) { UISearchDisplayController *searchDisplayController = navigationController.topViewController.searchDisplayController; [searchDisplayController.searchBar setHidden:YES]; } }