访问数据searchDisplayController处于活动状态

时间:2011-04-11 15:51:21

标签: objective-c core-data uisearchdisplaycontroller

我的iPhone应用程序正在使用Core Data,UISearchBar,UISearchDisplayController,UITableView和UIActionSheet。当没有执行搜索时,我可以确定用户选择了哪一行,但是如果搜索处于活动状态并且用户对特定行进行了选择,那么如何确定用户选择了哪一行?

示例:当NO SEARCH为ACTIVE时,以下代码无错误地运行:

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
    NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
    Event *event = (Event *)[[self fetchedResultsController] objectAtIndexPath:selectedIndexPath];    
    [self showURL:[NSURL URLWithString:event.siteSite] withTitle:@""];

但是,如果我使用上述方法确定相应的“event.siteSite”或URL,则URL为NULL,而[self.searchDisplayController isActive]等于 为真。

1 个答案:

答案 0 :(得分:1)

当您使用UISearchDisplayController时,您会获得第二个超强的第二个tableview。您必须查询tabelview才能找出所选的行。

有关详细信息,请参阅UISearchDisplayController Class Reference

相关问题