当第一个在第二个上移动时,NSView在另一个NSView上留下工件 [英] NSView leaves artifacts on another NSView when the first is moved across the second

查看:52
本文介绍了当第一个在第二个上移动时,NSView在另一个NSView上留下工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSView子类,可以在其超级视图中拖动它。我通过在mouseDragged事件处理程序中调用NSView的setFrameOrigin和setFrameRotation方法来移动视图。每个调用都会同时移动和旋转视图。

I have an NSView subclass that can be dragged around in its superview. I move the views by calling NSView's setFrameOrigin and setFrameRotation methods in my mouseDragged event handler. The views are both moved and rotated with each call.

我有一个视图包含多个视图实例。我遇到的问题是,当一个视图拖到另一个视图上时,它会在遮挡的视图上留下工件。我录制了这方面的简短视频。不幸的是,由于视频压缩,这些伪影不是很明显。

I have multiple instances of these views contained by a single superview. The problem I'm having is that, as one view is dragged over another, it leaves artifacts behind on the view it's eclipsing. I recorded a short video of this in action. Unfortunately, due to the video compression the artifacts aren't very visible.

我强烈怀疑这与同步平移和旋转有关。 Quartz Debug显示,当另一个视图在矩形上拖动时,该矩形的视图会被更新(此处的视频);

I strongly suspect that this is related to the simultaneous translation and rotation. Quartz Debug reveals that a rectangle of the occluding (or occluded) view is updated as another view is dragged across it (video here); somehow this rectangle is getting miscalculated by the drawing engine, so part of the view that should be redrawn isn't.

踢球者是我不知道如何解决此问题的方法。我找不到在文档中手动指定更新版本的任何方法,也不确定这是需要做的事情。有任何想法吗?谢谢!

The kicker is I have no idea how to fix this. I can't find any way to manually specify the update rect in the docs, nor am I sure that's what needs to happen. Any ideas? Thanks!

推荐答案

您还可以考虑使用CALayers而不是视图。与视图不同, 层旨在与同级堆叠。

You might also consider using CALayers instead of views. Unlike views, layers are intended to be stacked with their siblings.

对于可能的省力解决方案,请尝试使视图具有层级支持;它可能会或可能不会解决此问题,但是值得一试。

For a possible least-effort solution, try making the views layer-backed; it may or may not solve this problem, but it's worth a try.

这篇关于当第一个在第二个上移动时,NSView在另一个NSView上留下工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆