ABPersonViewController无法以可编辑模式打开

时间:2011-06-03 12:04:04

标签: ios iphone abpersonviewcontroller

ABPersonViewController未以可编辑模式打开。当我使用断点时,控件没有到达委托方法。问题出在哪儿?这是我的代码:


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Fetch the address book 
    if ((people != nil) && [people count])

    {   ABAddressBookRef addressBook = ABAddressBookCreate();
        //ABPersonViewController *personController = [[ABPersonViewController alloc] initWithNibName:@"ABPersonViewController" bundle:nil];

        ABRecordRef person = (ABRecordRef)[people objectAtIndex:indexPath.row];     
        ABPersonViewController *personController = [[[ABPersonViewController alloc] init]autorelease];

        personController.addressBook = addressBook;
        personController.personViewDelegate = self;
        personController.displayedPerson = person;
        personController.allowsEditing = YES;       
        //navigationController = [[UINavigationController alloc] init] ;
        [self presentModalViewController:personController animated:YES];
        //[self.navigationController pushViewController:personController animated:YES];
        //[personController release];   
    }   
    else 
    {
        // Show an alert if "KETAN" is not in Contacts
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                                                        message:@"Could not find naina in the Contacts application" 
                                                       delegate:nil 
                                              cancelButtonTitle:@"Cancel" 
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    [people release];

}



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

1 个答案:

答案 0 :(得分:0)

关于可编辑模式,您正走在正确的轨道上。但是,您首先需要从导航控制器推送ABPersonViewController(请参阅documentation