我在RafałAugustyniak的https://github.com/Augustyniak/RATreeView使用RATreeView组件。
使用github上的发布/演示代码:
添加:
RADataObject *rdo = [self.data objectAtIndex:0];
[self.treeView expandRowForItem:[rdo.children objectAtIndex:0]];
位于viewWillAppear的底部。
将手机对象的行更改为:
(void)loadData
{
RADataObject *phone2 = [RADataObject dataObjectWithName:@"Phone 2" children:nil];
RADataObject *phone3 = [RADataObject dataObjectWithName:@"Phone 3" children:nil];
RADataObject *phone4 = [RADataObject dataObjectWithName:@"Phone 4" children:nil];
RADataObject *phone1 = [RADataObject dataObjectWithName:@"Phone 1" children:[NSArray arrayWithObjects:phone2, phone3, phone4, nil]];
RADataObject *phone = [RADataObject dataObjectWithName:@"Phones"
children:[NSArray arrayWithObjects:phone1, nil]];
(这给出了一个嵌套列表,其中phone - > phone 1 - > phone2,phone3,phone4)
这会重现我在我的应用中出现的崩溃。
它崩溃了:
(void)expandCellForTreeNode:(RATreeNode *)treeNode withRowAnimation:(RATreeViewRowAnimation)rowAnimation
使用EXC_BAD_ACCESS:
[self.tableView endUpdates];
我已经追踪了几天,并且不确定如何解决这次崩溃(甚至是为什么会发生这种情况)。
答案 0 :(得分:1)
我使用您的代码获得的错误消息如下。要重现此错误,请移动
[self.treeView expandRowForItem:[rdo.children objectAtIndex:0]];
至viewDidAppear
。
由于未捕获的异常而终止应用 ' NSInternalInconsistencyException',原因:'无效更新:无效 第0节中的行数。包含在中的行数 更新后的现有部分(24)必须等于数量 在更新(12)之前,该部分中包含的行加或减 从该部分插入或删除的行数(插入24行, 删除0)加上或减去移入或移出的行数 该部分(0移入,0移出)。'
行数已更改为24,复制现有行并将其插入表中,但插入不成功。
您想要做的事情似乎是扩展子节点,您可以通过查看didSelectRowAtIndexPath
委托方法的实现来实现,因为扩展行就像点击一行一样。要手动添加以下代码。
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
RATreeNode *treeNode = [self.treeView treeNodeForIndexPath:indexPath];
[self.treeView expandCellForTreeNode:treeNode];
NSIndexPath *indexPath1 = [NSIndexPath indexPathForRow:1 inSection:0];
RATreeNode *treeNode1 = [self.treeView treeNodeForIndexPath:indexPath1];
[self.treeView expandCellForTreeNode:treeNode1];
就像你按顺序点击第0行和第1行一样。您还需要导入此头文件。
#import "RATreeView+Private.h"