Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UISearchDisplayController未显示任何单元格_Iphone_Objective C_Cocoa Touch_Uisearchbar_Uisearchdisplaycontroller - Fatal编程技术网

Iphone UISearchDisplayController未显示任何单元格

Iphone UISearchDisplayController未显示任何单元格,iphone,objective-c,cocoa-touch,uisearchbar,uisearchdisplaycontroller,Iphone,Objective C,Cocoa Touch,Uisearchbar,Uisearchdisplaycontroller,我有一个在Interface Builder中正确连接的UISearchDisplayController delegate = Files Owner searchBar = Search Bar searchContentsController = Files Owner searchResultsDataSource = Files Owner searchResultsDelegate = Files Owner 当my UITableView调用NumberRowsInSection

我有一个在Interface Builder中正确连接的UISearchDisplayController

delegate = Files Owner
searchBar = Search Bar
searchContentsController = Files Owner
searchResultsDataSource = Files Owner
searchResultsDelegate = Files Owner
当my UITableView调用
NumberRowsInSection:
时,将返回正确的号码

但是,
cellforrowatinexpath:
中的我的单元格甚至无法到达:

- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

 if (tblView == searchController.searchResultsTableView){
  NSLog(@"search will go here");
  UITableViewCell* cell = [self provideSearchQueryCells:tblView identifer:@"searchQueryCell"];
  STSymbol *aSymbol = [self.searchQueryResults objectAtIndex:indexPath.row];

  cell.textLabel.text = aSymbol.symbol;
  cell.detailTextLabel.text = aSymbol.symbol_title;

  return cell;
 }
 else { ... }
它总是转到else条件


我不太清楚原因。

这是对代码的一个猜测,但我们是在看搜索显示控制器本身吗?也许您的
self.searchDisplayController.searchResultsTableView
应该是
self.searchResultsTableView


如果不了解您的委托,我无法确定。

我需要创建UISearchDisplayController的实例,而不是使用self.searchDisplayController。

使用以下命令。它应该会起作用

 if ([tblView isEqual:[searchController searchResultsTableView]]) {
...
}
您还应确保搜索结果行数正确,如下所示:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    if ([tblView isEqual:[searchController searchResultsTableView]]) {
        return [self.searchResults count];
    }
...
}

我相信是这样,因为这段代码位于UITableViewController子类中。self.searchResultsTableView不是UITableViewController中的属性。我修改了我的帖子,以显示代理在IB中的连接方式。