0

I am developing an iOS application. I have used ABPeoplePickerNavigationController. If ABPeoplePickerNavigationController screen open with presentModalViewController method from another screen also opened with presentModalViewController method then application crash.

Below is the sample code. How can I correct it?

-(IBAction)showContacts:(id)sender{

//    ContactListScreen *contact = [[[ContactListScreen alloc] initWithTarget:self selector:@selector(loadSelectedPerson:)] autorelease];
//    [self presentModalViewController:contact animated:YES];

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    // place the delegate of the picker to the controll
    picker.peoplePickerDelegate = self;


    if ([Helper isIOS7]) { //IOS_7_Fix
        picker.topViewController.navigationController.navigationBar.barTintColor = [UIColor blackColor];
        picker.topViewController.navigationController.navigationBar.translucent = NO;
    }

    // showing the picker
    [self presentModalViewController:picker animated:YES];
    // releasing
    [picker release];


}

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

    NSString *firstName = ( NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    NSString *lastName =  ( NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
    NSString *phone =  @"";



    [self dismissModalViewControllerAnimated:YES];

    return NO;
}

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
    // assigning control back to the main controller
    [self dismissModalViewControllerAnimated:YES];
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
    return NO; 
}
hiwordls
  • 781
  • 7
  • 17
  • 35
  • What is the crash? An exception? A signal? Also, you are using a deprecated API. Use `presentViewController:animated:completion:` instead. – Léo Natan Oct 04 '13 at 15:22
  • Other than using deprecated methods (which would not appear to be the source of the problem), I don't see any issues here. You must identify the source of the crash. Try turning on [exception breakpoints](https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html). If that doesn't identify particular issue, share the stack trace with us and any other particulars you may have. – Rob Oct 04 '13 at 15:35
  • 1
    I am experiencing something similar. Did you find the source of the error? – Robert Feb 14 '14 at 23:11

0 Answers0