0

所以这是场景,我有一个 SearchController,它显示来自我的应用程序联系人列表的过滤结果,并且也出现在我的地址簿中。

推送 ABPersonViewController 的代码存在于我的 didSelectObject:atIndex 方法中。这是代码:

TableCellClass *selectedCell= (TableCellClass *)[self.tableView cellForRowAtIndexPath:indexPath];

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef arrayOfAllPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
ABRecordRef thisPerson = CFArrayGetValueAtIndex(arrayOfAllPeople,selectedCell.contactIndex);
ABPersonViewController *picker = [[ABPersonViewController alloc]init];
picker.personViewDelegate = self;
picker.displayedPerson = thisPerson;
picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];

这个代码块在标准的 TTTableViewController 上工作得很好,但不知何故不能在我的 searchController 上工作。

在此处输入图像描述

顺便说一下,这是屏幕截图。如您所见,不存在 NavigationController。这是 Three20 的默认设置。带有地址簿图标的单元格是通过点击手势启动 ABPersonViewController 的项目

4

2 回答 2

0

您的 searchController 是如何呈现的?它有导航控制器吗?

检查self.navigationController不为零。

于 2011-11-15T08:57:12.280 回答
0

所以我找到了解决我的问题的方法。

首先,我创建了一个类,它是 ABPersonViewController 的子类。然后创建了我自己的 -initWithNavigatorURL:query: 方法。

在作为我的 SearchDisplayController 的 TTTableViewController 类上,在 -didSelectObject:atIndexPath: 方法内,我有这段代码:

TTTableItemCell *selectedCell= (TTTableItemCell *)[self.tableView cellForRowAtIndexPath:indexPath];

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef arrayOfAllPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

ABRecordRef thisPerson = CFArrayGetValueAtIndex(arrayOfAllPeople,selectedCell.contactIndex);
ABPersonViewController *picker = [[ABPersonViewController alloc]initWithNibName:nil bundle:[NSBundle mainBundle]];
picker.personViewDelegate = self;
picker.displayedPerson = thisPerson;
picker.allowsEditing = YES;

NSNumber *allowsEditing;

if (picker.allowsEditing) {
    allowsEditing = [[NSNumber alloc]initWithInt:1];
}
else{
    allowsEditing = [[NSNumber alloc]initWithInt:0];
}

TTURLAction *urlAction = [[[TTURLAction alloc] initWithURLPath:@"tt://GJABPersonView"] autorelease];
urlAction.query = [NSDictionary dictionaryWithObjects:[NSMutableArray arrayWithObjects:self, thisPerson,allowsEditing, nil] forKeys:[NSMutableArray arrayWithObjects:@"personViewDelegate",@"displayedPerson",@"allowsEditing", nil]];
urlAction.animated = YES;
[[TTNavigator navigator] openURLAction:[urlAction applyTransition:UIViewAnimationTransitionFlipFromLeft]];
[allowsEditing release];

它不像导航时通常那样动画,但它可以工作:)

于 2011-11-17T07:47:21.027 回答