尝试移动UITableView行时发生崩溃 [英] Crashing while trying to move UITableView rows

查看:132
本文介绍了尝试移动UITableView行时发生崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UITableView 中有一些相当复杂的移动行的规则。每个部分有未定义的部分和行数,并且根据各种规则,用户可以在部分内或部分之间将行移动到特定的其他位置。

I've got some rather complicated rules for moving rows around in a UITableView. There are an undefined number of sections and rows per section, and based on various rules, rows can be moved within or between sections by the user to specific other locations.

全部的数据更新,一切正常。但是偶尔,在移动一行后,应用程序将会退出,突然之间会有一个空白空间,其中应该显示一行。

All of the data updating and everything is working. But occasionally, after moving a row, the app will wig out and suddenly there will be an empty space where a row should be displayed.

我使用的是

              - (NSIndexPath *)tableView:(UITableView *)tableView
targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath

来指定用户根据单元格所在的位置来拖动行的位置。 98%的时间工作。但在某些情况下,当用户只允许在部分之间拖动(不能重新排序部分中的行)时,会出现此错误,然后滚动到没有行的区域后,应用程序崩溃。

to specify where the user is allowed to drag the rows based on where the cell is. 98% of the time it works. But in some cases, when the user is only allowed to drag between sections (can't reorder rows within the section) this error appears, then the app crashes after scrolling over the area with no row.

抛出的异常是非常无用的:

The exception thrown is pretty useless:


由于未捕获异常NSRangeException而终止应用程序,原因: ** - [NSCFArray objectAtIndex:]:index(6)超出边界(6)

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (6) beyond bounds (6)

我的代码都不在堆栈上。最后一个UITableView特定方法是

None of my code is on the stack. The last UITableView-specific method is

- [UITableView(UITableViewInternal)_visibleCellForGlobalRow:]

有没有人看到这个问题发生之前?任何想法?

Has anybody seen this issue occur before? Any ideas?

推荐答案

我没有访问这个问题相当一段时间。我想出的解决方案是删除复杂的规则。不知道为什么他们允许使用复杂的规则,如果它崩溃的应用程序使用它们。不确定这是否在最新版本的操作系统中是固定的。

I haven't visited this problem in quite awhile. The solution I came up with was removing the complicated rules. Not sure why they allowed usage of complicated rules if it crashed the application when using them. Not sure if this is fixed in the latest version of the OS or not.

这篇关于尝试移动UITableView行时发生崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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