Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:], /SourceCache/UIKit/UIKit-2380.17/UITableViewRowData.m:400
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:'Failed to allocate data stores for 997008923 rows in section 0. Consider using fewer rows'
我的代码为什么声明失败 - [UISectionRowData refreshWithSection:tableView:tableViewRowData:]?
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [appDelegate.purchaseArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
return cell;
}
-(void)viewWillAppear:(BOOL)animated
{
[cartTbl reloadData];
}
我没有得到什么这是问题吗?
不幸的是,当您创建/修改它们时,Apple不会仔细检查许多UI对象上的参数,并且在检测到不一致时选择不使用信息性错误消息。但基本上这个断言意味着你已经在你的表格控件中隐藏了一些东西。首先确保你已经设置了'delegate'和'dataSource'。 – 2013-03-20 12:04:53
但仔细检查后,请参阅“无法为第0部分中的997008923行分配数据存储。请考虑使用更少的行”。我怀疑purchaseArray.count实际上有很多行,但不知何故该值必须被忽略。在numberOfRowsInSection中添加一个NSLog以记录返回值。 – 2013-03-20 12:09:02
它在模拟器中运行正常,但不能在设备上运行。 – user2071201 2013-03-20 12:29:34