首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ABPersonViewController在推送时不会显示

ABPersonViewController在推送时不会显示
EN

Stack Overflow用户
提问于 2011-11-15 15:17:52
回答 2查看 604关注 0票数 0

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

推送ABPersonViewController的代码出现在我的didSelectObject:atIndex方法中。代码如下:

代码语言:javascript
复制
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的项目

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-11-17 15:47:21

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

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

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

代码语言:javascript
复制
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];

它在导航时不会像正常情况下那样具有动画效果,但它可以完成以下工作:)

票数 0
EN

Stack Overflow用户

发布于 2011-11-15 16:57:12

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

检查self.navigationController是否不为空。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8132768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档