0

我正在开发一个 iOS 应用程序。我用过 ABPeoplePickerNavigationController。如果 ABPeoplePickerNavigationController 屏幕使用 presentModalViewController 方法从另一个屏幕打开,也使用 presentModalViewController 方法打开,则应用程序崩溃。

下面是示例代码。我该如何纠正?

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

0 回答 0