从IBAction中找到NSOutlineView中的确切位置

时间:2014-11-07 15:31:44

标签: objective-c nsoutlineview

我有一个NSOutlineView,我正试图在上面的视图中按下按钮时插入一个新行。

视图显示在大纲视图中,但位置错误。我怀疑这是大纲视图的嵌套性质。

我的自定义NSTableCellView中包含以下代码。

- (IBAction)reply:(id)sender {
    CustomOutlineView *ov = (id)[[self superview] superview];
    CustomTableCellView *cell = [[CustomTableCellView alloc] init];
    DataSource *ds = (id)ov.dataSource;

    long row = [ov rowForView:self];

    [ds.commentsArray insertObject:cell atIndex:row+1];
    [ov reloadData];
}

这会将视图插入父级下方。我想要做的是将它插入按钮所在的视图下方。

所以我的问题如下:在使用NSOutlineViews时,我究竟如何确定在哪里插入新视图。

提前致谢。

0 个答案:

没有答案