所以这里是scenarion,我有一个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的项目答案 0 :(得分:0)
您的searchController是如何呈现的?它有导航控制器吗?
检查self.navigationController
是否为零。
答案 1 :(得分: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];
它不像通常在导航时那样动画,但它完成了工作:)