将前景层添加到 IKImageBrowserView 项目并启用垃圾收集时,CALayer 闪烁

发布于 2024-09-24 02:27:34 字数 799 浏览 2 评论 0原文

我正在尝试实现一种类似于 Apple 的 ImageBrowserViewAppearance 示例代码中的技术(位于此处: http://developer.apple.com/library/mac/#samplecode/ImageBrowserViewAppearance/Introduction/Intro.html ),其中 CALayers 生成在项目顶部IKImageBrowserView 用于自定义图像浏览器中对象的外观。

然而,当我打开垃圾收集时,我遇到了一个奇怪的问题,我可以在Apple示例代码中重现它。只需在目标中打开垃圾收集,然后构建并启动 ImageBrowserAppearance 示例应用程序即可。然后,使用“添加照片...”按钮将一些照片添加到图像浏览器。

现在,单击 IKImageBrowserView 的空白部分,然后单击并拖动以开始在浏览器视图中选择多个项目。当您拖动选择框时,您应该注意到有时某些项目的图钉和光泽叠加会闪烁并短暂出现在 IKImageBrowserView 的左下角。所有 CALayers 似乎偶尔都会这样做,我也看到白色周围的幻灯片区域也闪烁到左下角。

当我在自己的代码中模仿该技术时,我(毫不奇怪)也可以重现此徽章闪烁。然而,当垃圾收集关闭时,这个问题就会消失。

有人知道这里可能出了什么问题吗?我想在我的应用程序中结合使用垃圾收集和这种技术,但闪烁有点烦人。

I'm trying to implement a technique similar to the one in the ImageBrowserViewAppearance sample code from Apple (located here: http://developer.apple.com/library/mac/#samplecode/ImageBrowserViewAppearance/Introduction/Intro.html ), where CALayers are generated on top of the items in the IKImageBrowserView to customize the appearances of the objects in the image browser.

However, I'm getting a weird problem when I turn on garbage collection, and I can reproduce it in the Apple sample code. Simply turn on Garbage Collection in the target, and build and launch the ImageBrowserAppearance sample app. Then, add some photos to the image browser using the "Add Photos..." button.

Now, click on an empty portion of the IKImageBrowserView, and click and drag to start selecting multiple items in the browser view. As you drag the selection box around, you should notice that sometimes the pin and gloss overlay for some of the items flicker and briefly appear in the bottom-left corner of the IKImageBrowserView. All of the CALayers seem to do this occasionally, I've seen the white surrounding slide area flicker down into the bottom-left corner as well.

When I mimic the technique in my own code, I (not surprisingly) also can reproduce this badge flickering. However, this problem disappears when garbage collection is off.

Anybody have a clue what could be going wrong here? I'd like to use garbage collection in my app in conjunction with this technique, but the flickering is kind of annoying.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光沙漏 2024-10-01 02:27:34

我不久前为添加了书签,但Apple更改了URL并且文本。幸运的是,当我将其添加为书签时,我引用了它:

对于编译为使用垃圾收集的应用程序,核心图形 API (Quartz 2D) 的绘图性能降低了大约 25%。

“绘图性能降低 25%”文本已被重写为“代码执行的轻微开销”,这是针对 10.5 的。也许 Apple 在 10.6 中修复了这个问题。你说的是核心动画,而不是核心图形。

尽管如此,核心动画最终还是必须与核心图形对话,也许性能问题还没有消失,而你却被它困扰了。

I bookmarked this a while back but Apple's changed the URL and the text. Fortunately I quoted it when I bookmarked it:

The Core Graphics APIs (Quartz 2D) see an approximately 25% reduction in drawing performance for applications compiled to use garbage collection.

That "25% reduction in drawing performance" text has been rewritten into a "slight overhead in code execution" and that was for 10.5. Perhaps Apple fixed it for 10.6. And you're talking Core Animation, not Core Graphics.

Still, Core Animation eventually has to talk to Core Graphics, and perhaps that performance issue hasn't gone away, and you're being bitten by it.

神回复 2024-10-01 02:27:34

我对此进行了一些愚弄,并可以确认我在打开 GC 的情况下运行项目时得到了相同的行为。事实上,如果您有足够的耐心并使用箭头键一次慢慢地更改选择一张图像,最终它会触发该行为,您可以看到视图中一张图像的图层显示在左下角而不是在图像的顶部。我无法找到任何关于它何时发生的模式,或者选择哪个图像与哪个图像丢失图层之间的任何关系。我假设无论出于何种原因,这些层的帧原点设置为 {0, 0},但如果我知道为什么的话,那见鬼。

I fooled around with this a bit and can confirm I get the same behavior running the project with GC turned on. In fact, if you're patient enough and slowly change the selection one image at a time using the arrow keys, eventually it'll trigger the behavior and you can see the layers from one image in the view are displayed in the lower left corner instead of on top of the image. I haven't been able to find any sort of pattern as to when it happens, or any relation between which image is selected and which image has its layers missing. I'm assuming that for whatever reason, those layers are getting their frame origin set to {0, 0}, but heck if I know why.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文