public
Last active

hide "Cancel" button ABPeoplePickerNavigationController and add another button performs like Cancel button.

  • Download Gist
gistfile1.m
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//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;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.