Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.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
Ios7 “搜索显示控制器”始终返回“真”和更多单元格_Ios7_Uisearchdisplaycontroller - Fatal编程技术网

Ios7 “搜索显示控制器”始终返回“真”和更多单元格

Ios7 “搜索显示控制器”始终返回“真”和更多单元格,ios7,uisearchdisplaycontroller,Ios7,Uisearchdisplaycontroller,我正在尝试使用UISearchDisplayController过滤出表视图中的单元格,但当我的单元格少于7个(与iphone屏幕大小相当)时,这种方法就可以正常工作。当我试图搜索超过7个单元格的视图控制器时,应用程序就会崩溃,因为在我开始键入之前,self.searchDisplayController.active总是返回true 下面是我的应用程序崩溃的代码片段: - (UITableViewCell *)tableView:(UITableView *)tableView cellFor

我正在尝试使用
UISearchDisplayController
过滤出表视图中的单元格,但当我的单元格少于7个(与iphone屏幕大小相当)时,这种方法就可以正常工作。当我试图搜索超过7个单元格的视图控制器时,应用程序就会崩溃,因为在我开始键入之前,
self.searchDisplayController.active
总是返回true

下面是我的应用程序崩溃的代码片段:

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

    SubRefCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"TableCell"forIndexPath:indexPath];

    if (cell == nil) {
        NSLog(@"cell is nill");
        cell = [[SubRefCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TableCell"];
    }

    int row=[indexPath row];

    if (self.searchDisplayController.active) { //is always true when more than 7 cells
        NSLog(@"Here is the table of results: %@",self.searchResults);
        cell.subRefLabel.text = self.searchResults[row];
        NSLog(@"failed ");
        cell.subRefDescLabel.text = _Refs.SubRefDesc[row]; //fix later


    } else {
        //set all the cells with the Sub Reference names and their descriptions
        cell.subRefLabel.text = _Refs.SubReference[row];
        cell.subRefDescLabel.text = _Refs.SubRefDesc[row];
    }

    return cell;
}
在其他情况下,如果我的单元格少于7个,
self.searchDisplayController.active
将返回false,直到我开始在搜索栏中键入

以下是我得到的错误:
*-[\uu NSArrayI objectAtIndex:]:索引7超出空数组的界限'*


为什么当有超过iphone屏幕大小的单元格时,searchDisplayController.active会为真?

在每个TVC数据源方法中,您是否正在检查是否为主表视图
self.tableView
UISearchDisplayController
表视图
self.searchDisplayController.searchResultsTableView
提供信息?