【问题标题】:donot open ABPersonViewController不要打开 A Person ViewController
【发布时间】:2011-09-07 14:48:15
【问题描述】:

我正在尝试在表委托方法 (DidSelectRowAtIndex) 中打开 ABPersonViewController。但是当我在表格视图中点击我的一位联系人时,它会显示“obj msg send”。帮我 这是我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // 获取通讯录 if ((people != nil) && [人数统计]) { ABAddressBookRef addressBook = ABAddressBookCreate(); //ABPersonViewController *personController = [[ABPersonViewController alloc] initWithNibName:@"ABPersonViewController" bundle:nil]; ABRecordRef person = (ABRecordRef)[people objectAtIndex:indexPath.row]; ABPersonViewController *personController = [[ABPersonViewController alloc] init]; personController.addressBook = 地址簿; personController.personViewDelegate = 自我; personController.displayedPerson = 人; personController.allowsEditing = YES; //navigationController = [[UINavigationController alloc] init] ; [自我presentModalViewController:personController动画:YES]; //[self.navigationController pushViewController:personController Animation:YES]; [personController 发布]; } 别的 { // 如果“KETAN”不在通讯录中,则显示警报 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 消息:@“在联系人应用程序中找不到 naina” 代表:无 cancelButtonTitle:@"取消" 其他按钮标题:无]; [警报显示]; [警报发布]; } [人民释放]; }

【问题讨论】:

  • 你想达到什么目的?是否要获取联系人信息?
  • @marvin:当我在可编辑模式下选择联系人的任何名称时,我需要打开 ABPersonViewController。

标签: iphone


【解决方案1】:

如果要在编辑模式下打开personview,除了allowsEditing = YES,还需要指定setEditing:YES

[personController setEditing:YES animated:NO];       

【讨论】:

    【解决方案2】:

    你在这里做了一个不必要的发布,CFRelease(person);。您只是直接从数组中获取值,因此您不应该释放它。此外,ABPersonViewController 对象不保留分配给displayedPersonperson 对象,因此在尝试访问已释放的对象时会导致错误。

    【讨论】:

    • person 包含有关联系人的信息..所以我该怎么办?
    • 当我使用 presentmodal 视图控制器时,它显示 ABPersonviewcontroller 而没有编辑模式。但是当我使用导航时,它会终止。我想我的导航不起作用..
    • 我已经在编辑后的代码上运行,但控制器仍处于不可编辑模式。编辑按钮未显示。
    • @deepak: 为什么它没有在编辑模式下打开....请帮助我!!我已经编辑了代码..ABPersonViewController 中缺少导航栏
    • 我真的不确定,但我已经创建了一个quick project,它正在工作。看看有没有帮助。
    【解决方案3】:

    在你的代码中使用这一行而不是那一行,

    ABPersonViewController *personController = [[ABPersonViewController alloc] initWithNibName:@"ABPersonViewController" bundle:nil];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多