为什么在[[UISectionRowData refreshWithSection:tableView:tableViewRowData:]中断言失败? [英] why Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]?

查看:43
本文介绍了为什么在[[UISectionRowData refreshWithSection:tableView:tableViewRowData:]中断言失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 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];

}

我没有遇到什么问题吗?

i didn't get what's problem in this?

推荐答案

检查您的 tableView:heightForRowAtIndexPath:.也许您返回的是 NaN / + inf / -inf 而不是高度.那是我的错误.

Check your tableView:heightForRowAtIndexPath:. Maybe you're returning something like NaN/+inf/-inf instead of height. That was my bug.

请记住,对于 double float 类型除以零,这不是崩溃:

Remember this is not a crash for double and float types to divide by zero:

double d = 5.0;
double r = d/0.0;

这样可以为您提供帮助:

So this can help you:

if (isnan(r) || isinf(r)) {
    // ...
}

这篇关于为什么在[[UISectionRowData refreshWithSection:tableView:tableViewRowData:]中断言失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆