Dealing with layer-backed IKImageBrowserView, Z-ordering and other concerns

547 views Asked by At

I am working on a project that needs to:

  • have a transition animation from a view that contains an IKImageBrowserView to another view;
  • have a hover overlay on each IKImageBrowserCell as the mouse moves across the view; and
  • have an NSView overlap a portion of the image browser view

The issues I am having are the following:

  • The IKImageBrowserView does not respect the z-ordering if it is not layer-backed --> the IKImageBrowserView stays on top regardless even if a view is on top of it (or in it for that matter)
  • If the image browser view is layer-backed, the z-ordering issue gets resolved but the custom-behaviour in the IKImageBrowserView breaks (e.g. hovers) --> In Mac 10.7 for example, the selection layer and the foreground layer of the browser cell don't move with the image in the "bounce" zone of the scroll view.

I need layer-backing to do the transition animations.

For performance reasons, I am aware that Apple does not advise sibling views overlapping. There are instances though that this cannot be avoided.

I have submitted a technical support incident to Apple about this. They have escalated it to the engineers but they also advised me to submit a bug report.

Has anyone has run into this before and if so what workaround did you employ?


For anyone who's curious, the sample project is here https://github.com/jdbenito/nerdery. In the app delegate, try commenting/uncommenting the -setWantsLayer: line.

The IKImageBrowserView start to exhibit weird behaviours when it is layer-backed. And the symptoms differ depending on the OS (e.g. In Mac OS 10.6, the hovers work until you switch to another tab and return back to the IKImageBrowserView. In Mac OS 10.8, the hover layers can't seem to render in the correct cell).

1

There are 1 answers

0
Johannes Fahrenkrug On

NSView siblings are definitely allowed to overlap. I had the same question a while ago and got confirmation from some Apple engineers: Are layer-backed NSView siblings allowed to overlap?

About the IKImageBrowserView: I'm under the impression that it is more or less intended to be used as a "black box", much like a UITableView on iOS: you can customize the cells and some behaviors, but you better not mess with its internal view hierarchy by adding subviews directly to it. If you need anything besides the standard, documented behavior, you might be better off writing your own solution. It shouldn't be overwhelmingly hard to do, especially because you have access to Image I/O for all your thumbnail and preview needs: https://developer.apple.com/library/mac/documentation/graphicsimaging/Conceptual/ImageIOGuide/imageio_source/ikpg_source.html#//apple_ref/doc/uid/TP40005462-CH218-SW3

Hope this helps!