向NSTableView添加新行后,我想滚动到它.
当该行已添加到表的末尾时,滚动仅滚动到之前最后一行的行.我最初认为我必须等待动画完成,但这并没有解决我的问题.这是我的代码:
[NSAnimationContext beginGrouping]; [_tableView insertRowsAtIndexes:indexSet withAnimation:NSTableViewAnimationEffectGap]; [[NSAnimationContext currentContext] setCompletionHandler:^{ // Scroll to the first inserted row NSUInteger firstIndex = [indexSet firstIndex]; [_tableView scrollRowToVisible:firstIndex]; }]; [NSAnimationContext endGrouping];
我怎样才能做到这一点?