Question

I have used ABNewPersonViewControllerDelegate in my project.It pops up new view for adding contact.

-(IBAction)Click:(id)sender
{
    ABNewPersonViewController *view = [[ABNewPersonViewController alloc] init];
    view.newPersonViewDelegate = self;

    UINavigationController *newNavigationController = [[UINavigationController alloc]
                                                       initWithRootViewController:view];
    [self presentModalViewController:newNavigationController
                            animated:YES];
}

How to handle cancel and done button?.any example code will be appreciated.thanks in advance

Was it helpful?

Solution

If you read the documentation, you will find that the ABNewPersonViewControllerDelegate method newPersonViewController:didCompleteWithNewPerson: returns NULL for the person argument if cancel is pressed.

OTHER TIPS

(void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person{

    if (person != nil) {

        [self.tableview reloadData];
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

This the code I'am using. If the user hits the cancel button the picker returns the null ABRecordRef, so we have to check if picker have returned us the record or nil value and proceed further as desired.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top