【发布时间】:2011-05-18 12:41:58
【问题描述】:
我有一个表格视图,我在其中从不同的笔尖加载了自定义单元格,但出现异常:
2011-05-18 18:01:00.323 custInfoService[4370:20b] *** 断言失败 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit/UIKit-984.38/UITableView.m:4709
2011-05-18 18:01:00.324 custInfoService[4370:20b] *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“UITableView 数据源必须从 tableView:cellForRowAtIndexPath 返回一个单元格:”
2011-05-18 18:01:00.325 custInfoService[4370:20b] 堆栈:(
11125851,
2442997307,
当我使用断点时,我才知道 xception 是在 switch case 中。我无法弄清楚为什么它会给出异常?帮我! 这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 静态 NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 如果(单元格 == 零) { [[NSBundle mainBundle] loadNibNamed:@"BookDetailViewController" owner:self options:NULL]; 单元格 = nibloadedcell; } tbcel.layer.cornerRadius = 10; tbcel.text = aBook.Name; UILabel *fieldlabel = (UILabel *) [cell viewWithTag:1]; fieldlabel.text = [fieldarray objectAtIndex:(indexPath.row)]; UILabel *valuelabel = (UILabel *) [cell viewWithTag:2]; 开关(indexPath.section) { 案例0: valuelabel.text = aBook.Address; 休息; 情况1: valuelabel.text = aBook.Phone; 休息; 案例2: valuelabel.text = aBook.Purchase; } 返回单元格; }【问题讨论】:
标签: iphone