macos – 动画完成后如何滚动到添加到NSTableView的行

macos – 动画完成后如何滚动到添加到NSTableView的行,第1张

概述向NSTableView添加新行后,我想滚动到它. 当该行已添加到表的末尾时,滚动仅滚动到之前最后一行的行.我最初认为我必须等待动画完成,但这并没有解决我的问题.这是我的代码: [NSAnimationContext beginGrouping]; [_tableView insertRowsAtIndexes:indexSet withAnimation:NSTableViewA 向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];

我怎样才能做到这一点?

解决方法 我找到了解决他的问题的方法,我很满意:

[_tableVIEw insertRowsAtIndexes:indexSet withAnimation:NStableVIEwAnimationEffectGap];[[NSOperationQueue mainQueue] addOperationWithBlock:^{    NSUInteger firstIndex = [indexSet firstIndex];    [_tableVIEw scrollRowToVisible:firstIndex];}];

我只是将滚动请求延迟到下一个运行循环.

总结

以上是内存溢出为你收集整理的macos – 动画完成后如何滚动到添加到NSTableView的行全部内容,希望文章能够帮你解决macos – 动画完成后如何滚动到添加到NSTableView的行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1001072.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存