如何强制重绘 NSScrollView 内的内容
我将 NSTextView + NSImageView + NSMatrix + NSTextView 放在 NSScrollView 中。我使用以下代码将此滚动视图滚动到顶部 -
NSPoint pointToScrollTo = NSMakePoint(0, NSMaxY([[singleScrollView documentView] frame]) - [[singleScrollView contentView] bounds].size.height);
[[singleScrollView contentView] scrollToPoint: pointToScrollTo];
[singleScrollView reflectScrolledClipView: [singleScrollView contentView]];
但问题是当它完成滚动到顶部时,视图会变得混乱。这是一个屏幕截图 -
我尝试使用此方法强制重绘内容,但没有成功 -
[txtQTitle setNeedsDisplay:YES];
[viewOptions setNeedsDisplay:YES];
[singleScrollView setNeedsDisplay:YES];
有人知道为什么会导致这种情况以及应该如何解决吗?
编辑 1 - 当我使用鼠标滚动视图时,singleScrollView 的某些部分就可以了..这是一个屏幕截图 -
I put NSTextView + NSImageView + NSMatrix + NSTextView in a NSScrollView. And I scroll this scrollview to top using following code -
NSPoint pointToScrollTo = NSMakePoint(0, NSMaxY([[singleScrollView documentView] frame]) - [[singleScrollView contentView] bounds].size.height);
[[singleScrollView contentView] scrollToPoint: pointToScrollTo];
[singleScrollView reflectScrolledClipView: [singleScrollView contentView]];
But the problem is when it finish scrolling to top the view gets messed up.. Here is a screenshot -
I tried to force redraw contents with no luck using this -
[txtQTitle setNeedsDisplay:YES];
[viewOptions setNeedsDisplay:YES];
[singleScrollView setNeedsDisplay:YES];
Do anyone have any idea why this is causing and how should be solved?
Edit 1 - When I scroll the view using mouse scroll some part of the singleScrollView gets ok .. here is a screenshot of this -
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
[[yourScrollView contentView] setCopiesOnScroll:NO]
。我想,它应该可以解决你的问题。Try with
[[yourScrollView contentView] setCopiesOnScroll:NO]
. I think, it should solve your problem.