After adding a new row to NSTableView, I would highlight it.
When this row is added to the end of the table, the scroll only scrolls to the row that was previously the last row. At first I thought I needed to wait for the animation to finish, but this did not solve my problem. Here is my code:
[NSAnimationContext beginGrouping];
[_tableView insertRowsAtIndexes:indexSet withAnimation:NSTableViewAnimationEffectGap];
[[NSAnimationContext currentContext] setCompletionHandler:^{
NSUInteger firstIndex = [indexSet firstIndex];
[_tableView scrollRowToVisible:firstIndex];
}];
[NSAnimationContext endGrouping];
How can i do this?
source
share