2

How can I dismiss the ABPersonViewController? Here is my code

 #pragma mark - Edit Record Method

-(void)btnEditContactTapped:(id)sender {

    // Fetch the address book 
    ABAddressBookRef addressBook = ABAddressBookCreate();

    ABRecordID recID = ABRecordGetRecordID(record);

    ABRecordRef record1 = ABAddressBookGetPersonWithRecordID(addressBook,recID);

    ABPersonViewController *personViewController = [[ABPersonViewController alloc]init];
    // set delegate
    personViewController.personViewDelegate = self;

    // Allow editing info
    personViewController.allowsEditing = YES;

    // Display contact info of selected person
    personViewController.displayedPerson = record1;

    // Person view controllers must be used with a navigation controller in order to function properly.
    UINavigationController *nc = [[UINavigationController alloc]
                                  initWithRootViewController:personViewController];
    [self presentModalViewController:nc animated:YES];
    [personViewController release];

}

#pragma mark - ABPersonViewControllerDelegate Method

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue {

    [self dismissModalViewControllerAnimated:YES];
    return NO;
}

record in my ivar declared as ABRecordRef record in .h file. ABPersonViewControllerDelegate method never gets called? What's going wrong? Any kind of help is appreciated. Thanks

Marco
  • 6,692
  • 2
  • 27
  • 38
iOSAppDev
  • 2,755
  • 4
  • 39
  • 77

1 Answers1

0

Have you implemented thesse protocols in .h of your project.. ?

< ABPeoplePickerNavigationControllerDelegate,
                                                                 ABPersonViewControllerDelegate,
                                                                 ABNewPersonViewControllerDelegate,
                                                                 ABUnknownPersonViewControllerDelegate>
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
  • Not all. I have only ABPersonViewControllerDelegate in my .h file. Why should I need all of the above? Also let me know which delegate methods do I need to implement. Thanks. – iOSAppDev Apr 18 '12 at 12:12
  • you don't need all I just mentioned them all as I can't se your full code... and if you are not getting any warning then you have all the methods you need to implement... other way to determine is to go the definition of ABPersonViewControllerDelegate and look for methods under the "required" heading.. – Ankit Srivastava Apr 18 '12 at 12:15
  • ABPersonViewControllerDelegate has only one method which I have implemented (shown in my code) . Still its not working. ANy idea? – iOSAppDev Apr 18 '12 at 12:42