免责声明:我向您保证,此问题与其他帖子不重复。我知道错误产生的时间,但可以确认,考虑到我在下面描述的情况,根本不应该产生这个错误。
我的UITableViewControllers
有一个问题。
当我通过parent TBVC
将child table view controller
中的原型单元格连接到modal transition
时,所有单元格都正确加载,并且信息也正确显示;这证明没有原型标识符链接问题。
但是,使用modal transition
导致我的导航栏消失,因此我选择标准的push
转换,这就是问题发生的地方。该程序产生Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit/UIKit-3318.16.21/UITableView.m:7344
错误。
这非常令人沮丧,因为在cellForRowAtIndexPath
方法中未生成单元格时通常会发生此错误。但是通过调试我可以看到细胞肯定是创造出来的:
2015-01-17 17:44:12.284 PK[448:29784] cellForRowAtIndexPath: 0
2015-01-17 17:44:12.294 PK[448:29784] self.daysLabel.text: Monday hoursLabel.text: 9:00am - 5:30pm
2015-01-17 17:44:12.294 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.299 PK[448:29784] cellForRowAtIndexPath: 1
2015-01-17 17:44:12.307 PK[448:29784] self.daysLabel.text: Tuesday hoursLabel.text: 9:00am - 5:30pm
2015-01-17 17:44:12.308 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.311 PK[448:29784] cellForRowAtIndexPath: 2
2015-01-17 17:44:12.320 PK[448:29784] self.daysLabel.text: Wednesday hoursLabel.text: 9:00am - 5:30pm
2015-01-17 17:44:12.320 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.324 PK[448:29784] cellForRowAtIndexPath: 3
2015-01-17 17:44:12.332 PK[448:29784] self.daysLabel.text: Thursday hoursLabel.text: 9:00am - 5:30pm
2015-01-17 17:44:12.332 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.336 PK[448:29784] cellForRowAtIndexPath: 4
2015-01-17 17:44:12.343 PK[448:29784] self.daysLabel.text: Friday hoursLabel.text: 9:00am - 5:30pm
2015-01-17 17:44:12.344 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.346 PK[448:29784] cellForRowAtIndexPath: 5
2015-01-17 17:44:12.350 PK[448:29784] self.daysLabel.text: Saturday hoursLabel.text: Closed
2015-01-17 17:44:12.351 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.353 PK[448:29784] cellForRowAtIndexPath: 6
2015-01-17 17:44:12.357 PK[448:29784] self.daysLabel.text: Sunday hoursLabel.text: Closed
2015-01-17 17:44:12.357 PK[448:29784] is cell nill: not nil
2015-01-17 17:44:12.361 PK[448:29784] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit/UIKit-3318.16.21/UITableView.m:7344
2015-01-17 17:44:12.366 PK[448:29784] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(0x184c2259c 0x1953800e4 0x184c2245c 0x185aa9554 0x18951391c 0x1896caf10 0x1896bfaa4 0x1894b4ce8 0x1893d1648 0x188d29994 0x188d24564 0x188d24408 0x188d23c08 0x188d2398c 0x188d1d3bc 0x184bdaa50 0x184bd79dc 0x184bd7dbc 0x184b050a4 0x18dca75a4 0x18943a3c0 0x1000fe31c 0x1959eea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
我还尝试手动链接两个视图控制器,而不是使用didSelect
方法并调用performSegue
方法,但是当尝试推送到子表视图控制器时,这也会产生相同的结果
有人可以告诉我如何解决这个问题。
更新1
根据@ paulw11的要求,这是cellForRowAtIndexPath
方法的样子。再次,这会在转换到表视图控制器modally
时正确加载所有单元格,但是当我将转换更改为push
样式时,会发生断言错误。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"cellForRowAtIndexPath: %lu", indexPath.row);
OXHoursTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCellIdentifierDaysSelection];
[cell updateCellWithObject:self.businessHours[indexPath.row]];
//In this method I simply grab the values of the object's attributes and assign them to the cell's two label's text property
NSLog(@"is cell nill: %@", cell == nil ? @"nil" : @"not nil");
return cell;
}