use*_*201 5 iphone uitableview
 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'
我的代码
 -(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];
}
我没有得到这个问题?
检查你的tableView:heightForRowAtIndexPath:.也许你会返回类似NaN/ +inf/ -inf而不是高度的东西.那是我的错.
请记住,这不是崩溃double和float类型除以零:
double d = 5.0;
double r = d/0.0;
所以这可以帮助你:
if (isnan(r) || isinf(r)) {
    // ...
}
我也失败了-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]。在我的情况下,这是由于estimatedRowHeight在使用时设置太小而引起的:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}
用于自动调整tableView的单元格。设置estimatedRowHeight以2.0代替1.0解决的问题。
| 归档时间: | 
 | 
| 查看次数: | 6339 次 | 
| 最近记录: |