Here is my UIBarButton:
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc]
initWithTitle:@"+ Contact"
style:UIBarButtonItemStylePlain
target:nil
action:@selector(showPicker:)] animated:YES];
Here is the code it’s supposed to launch:
- (void)showPicker:(id)sender {
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
When I launch the app and click on the ‘+ Contact’ UIBarButton, nothing happens. No errors, nada. I put in a breakpoint, and it never reaches the method referenced by the selector.
Am I doing something wrong in the way I’m calling the selector?
Thanks!
The declaration of your button is missing something, namely the
targetparameter. Try this:This assumes that
showPicker:is in fact in the same class that’s adding the button to the navigation item.The
targetparameter is the instance that should handle the event.