ABPersonViewController 未以可编辑模式打开

发布于 2024-11-13 15:36:38 字数 1978 浏览 5 评论 0原文

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

ABPersonViewController is not opening in editable mode. When I use break point then control is not reaching the delegate method. Where is the problem? Here is my code:


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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-11-20 15:36:38

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

You're on the right track regarding editable mode. However, you first need to push the ABPersonViewController from a navigation controller (see documentation)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文