Skip to content

Instantly share code, notes, and snippets.

@apisit
Created June 22, 2012 07:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apisit/2970980 to your computer and use it in GitHub Desktop.
Save apisit/2970980 to your computer and use it in GitHub Desktop.
hide "Cancel" button ABPeoplePickerNavigationController and add another button performs like Cancel button.
//picker is ABPeoplePickerNavigationController
[self presentModalViewController:picker animated:YES];
UIButton* backButton= [[UIButton alloc]initWithFrame:CGRectMake(9, 25, 35, 35)];
[backButton setImage:[UIImage imageNamed:@"btnBack.png"] forState:UIControlStateNormal];
[backButton addTarget:picker.topViewController.navigationItem.rightBarButtonItem.target action:picker.topViewController.navigationItem.rightBarButtonItem.action forControlEvents:UIControlEventTouchUpInside];
[picker.navigationBar.superview addSubview:backButton];
//or you can use leftBarButtonItem instead of UIButton
//picker.topViewController.navigationItem.leftBarButtonItem= [[UIBarButtonItem alloc]initWithCustomView:backButton];
picker.topViewController.navigationItem.rightBarButtonItem=nil;
//hide search bar in UITableView in ABPeoplePickerNavigationController
//NSLog(@"%d",picker.topViewController.view.subviews.count);
//NSLog(@"%@", [[picker.topViewController.view.subviews objectAtIndex:0] class]);
//UITableView* tableView=[picker.topViewController.view.subviews objectAtIndex:0];
//tableView.tableHeaderView=nil;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment