I am using ABNewPersonViewController
.
I am saving the Done button(rightBarButtonItem
of ABNewPersonViewController
) to another button, so that the delegate method
- (void)newPersonViewController:(ABNewPersonViewController *)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person
doesn't get called until done button is pressed. My viewDidLoad
method is as
- (void)viewDidLoad {
[super viewDidLoad];
self.defaultRightBarButtonItem = self.navigationItem.rightBarButtonItem;
UIBarButtonItem *saveBtn = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self
action:@selector(actionSave:)];
self.navigationItem.rightBarButtonItem = saveBtn;
[saveBtn release];
}
On the button click in another view I trigger the done button action
[self.defaultRightBarButtonItem.target
performSelector:self.defaultRightBarButtonItem.action
withObject:self.defaultRightBarButtonItem.target];
Sometimes the method gets called and sometimes doesn't work. If I just edit the email address field or phone number field of the contact and try to save that, the method gets called. But if I try to edit the address fields and then save, the method doesn't get called. What could be the reason for this.
Edit: Found out that the delegate method doesn't get triggered when a new view is loaded. And this happens(new view loaded) only when fields like Country, Ringtone gets edited. Thats when the delegate method is not triggered. In all other cases, the delegate method gets triggered. Now any suggestions?