IOS ABPeoplePickerNavigationController崩溃

时间:2013-10-04 14:53:50

标签: ios abpeoplepickerview

我正在开发一个iOS应用程序。我使用过ABPeoplePickerNavigationController。如果用另一个屏幕打开带有presentModalViewController方法的ABPeoplePickerNavigationController屏幕也用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; 
}

0 个答案:

没有答案