【问题标题】:UITableView: Application crashing in attempt of deleting a rowUITableView:应用程序在尝试删除行时崩溃
【发布时间】:2012-02-22 05:50:47
【问题描述】:

任何人都可以告诉我如何实现这一目标。我想用动画从tableview中删除一行。这是我的示例代码

    [section0ARR removeObjectAtIndex:row];
    NSIndexPath *index = [NSIndexPath indexPathForRow:section inSection:row];
    [myTableVEW beginUpdates];
    [myTableVEW deleteRowsAtIndexPaths:[NSArray arrayWithObject:index]    withRowAnimation:UITableViewRowAnimationFade];

    [myTableVEW endUpdates];

使用此断言尝试此操作时应用程序崩溃断言失败 -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046

但如果我只是重新加载我的表格,一切都会很好,但在这种情况下动画是不可见的。

这是一个清单

  1. 从数据源中删除了项目
    1. 使用动画从 tableview 中删除行

请帮助我摆脱崩溃。

问候 Ankit

【问题讨论】:

  • 你检查过numberOfRowsInSection:吗?
  • @Invincible yupp 我检查了它是否按预期跟踪我的代码,直到它在那之后崩溃
  • 试过使用tableView:commitEditingStyle:forRowAtIndexPath:?
  • @Invincible 当您使用“deleteRowsAtIndexPaths”时,它不会进入 commitEdittingStyle 方法
  • Hmm.. 那堂课的第 1046 行是什么?

标签: iphone uitableview


【解决方案1】:

尝试改变:

 NSIndexPath *index = [NSIndexPath indexPathForRow:section inSection:row];

对此:

 NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:section];

(我假设 rowsection 是有效值,因为我们没有其余代码。)

【讨论】:

  • 那是个错误,是的,你解决了问题
猜你喜欢
  • 2023-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-28
  • 2016-11-27
  • 1970-01-01
相关资源
最近更新 更多