【问题标题】:UISearchDisplayController doesn't fire didSelectRowAtIndexPathUISearchDisplayController 不会触发 didSelectRowAtIndexPath
【发布时间】:2013-08-28 18:52:49
【问题描述】:

我有一个UIViewController,里面有一个UISearchDisplayController。我让它显示搜索结果表格视图,但单击任何单元格都不会触发didSelectRowAtIndexPath:

#pragma mark - UITableViewDelegate
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"did select row");
}

我看过这些相关的问题:

但我没有犯同样的错误。视图控制器实现了UITableViewDelegateUISearchDisplayDelegateUISearchDisplayController 委托和 searchResultDelegate 连接到情节提要中的视图控制器。但为了确保我在viewDidLoad 中做了以下操作:

self.searchDisplayController.searchResultsDelegate = self; 
self.searchDisplayController.delegate = self; 

我什至尝试过:

self.searchDisplayController.searchResultsTableView.delegate = self;

searchResultsTableView 是此视图控制器中唯一的UITableView

【问题讨论】:

    标签: ios objective-c uitableview uisearchdisplaycontroller


    【解决方案1】:

    您在问题中显示的代码是 didDeselect,而不是 didSelect。因此,如果这就是您的代码中实际包含的内容,那就是问题所在。

    【讨论】:

    • 嗯。看那个。谢谢。
    • 还是不行。 #pragma mark - UITableViewDelegate -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"did select"); }
    • @dysfunction,当你点击一个单元格时,你会得到蓝色的选择颜色吗?
    • 不,我只有在点击并按住时才能得到它(这也不会触发 didSelectRowAtIndexPath)。
    • @dysfunction,这当然不是标准行为。您是否添加了任何手势识别器,或做过任何其他会使您的表格视图不标准的事情?
    猜你喜欢
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多