-1
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
if (tableView == self.searchDisplayController.searchResultsTableView) {
   return searchResults.count; 
} else { 
    return self.countOfLocArr.count;
} 
}

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

    AtmLocationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 
    if(!cell) { 
        AtmLocationTableViewCell *cell = [[AtmLocationTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    } 
    NSMutableDictionary *locDictionary; 
    if(tableView == self.searchDisplayController.searchResultsTableView) {
     locDictionary = searchResults[indexPath.row];
    }else{ } 
    cell.placeName.text = locDictionary[@"name"]; 
    return cell;
    }

得到错误

* -[UISearchResultsTableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UITableView.m:7971 2016-12-01 18:21 中的断言失败: 04.096 摩比 [6459:2145589] *由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“UITableView (; layer = ; contentOffset: {0, 0}; contentSize: {320, 396}>) 未能从其 dataSource () 获取单元格 *** First throw call stack: (0x20fb9b8b 0x20776dff 0x20fb9a61 0x217a072b 0x256d64a3 0x258d3cb9 0x258d3d91 0x258c326d 0x256673bd 0x2579129f 0x256ec46d 0x257923e3 0x257920bb 0x25791f2d 0x255c2521 0x255c24b1 0x255aa3eb 0x25791c75 0x255ccd9f 0x25760b5b 0x2575feed 0x258e967f 0x25ea5f73 0x2575fc53 0x2598e135 0x2598dd5f 0x255b5355 0x217e6867 0x20f7ba67 0x20f7b657 0x20f799bf 0x20ec8289 0x20ec807d 0x224e4af9 0x255f32c5 0xde303 0x20b74873) libc++abi.dylib : 以 NSException 类型的未捕获异常终止

4

2 回答 2

0

可能会发生cellForRowAtIndexPath正在返回的情况nil

检查这些:断言失败 1断言失败 2断言失败 3

于 2016-12-01T13:12:27.343 回答
0

检查这个:

1) 您从 tableView:numberOfRowsInSection: 返回一个大于数组计数的数字。不。

2) 您的一个或多个 cell# 插座未连接到您的笔尖,或者未连接到 UITableViewCell(或子类)。正确连接它们。

参考更多:https ://stackoverflow.com/a/14192093/3901620

于 2016-12-01T13:01:39.773 回答