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;
}