ios - ABPersonViewController 未以可编辑模式打开

标签 ios iphone abpersonviewcontroller

ABPersonViewController 未在可编辑模式下打开。当我使用断点时,控制不会到达委托(delegate)方法。哪里有问题?这是我的代码:


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

最佳答案

关于可编辑模式,您的方向是正确的。但是,您首先需要从导航 Controller 推送 ABPersonViewController(参见 documentation)

关于ios - ABPersonViewController 未以可编辑模式打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6226860/

相关文章:

ios - TableView 不重新加载数据

iphone - iOS:通过委托(delegate)方法从推送的 ViewController 返回?

iOS 7 - 为什么 ABPersonViewController 不显示我个人的所有信息?

ios - 在 IB 中,无法将 IBOutlet 委托(delegate)连接到另一个 View Controller ?

ios - Apple Watch WCSession 返回 watchAppInstalled false

iphone - NSPredicate 来查明实体的实例是否有父代?

iphone - 通过 IAP 每月订阅

ios - 无法访问地址簿的 Person ViewController

ios - 是否可以使用 ABPersonViewController 从我的 iOS 应用更新链接的联系人?

ios - 带有 LiveFrost LFGlassView 的 UIView 动画