Erroneous behavior with support for level / level based on NSViews

I have a view hierarchy that looks like this:

enter image description here

So basically I have an NSSplitView with a subview that contains a scroll view (for table view), as well as a footer view containing 3 subspecies. Some important points:

  • Uses 10.8 basic SDK, no auto layout
  • The view of the window contents, the split view, the parent view of the scroll and footer views, as well as the scroll and footer views - this is with the support of layers with NSViewContentsRedrawOnSetNeedsDisplay to redraw the policy.
  • NSClipView NSScrollView is a special subclass that represents the hosting level and uses CAScrollLayer as a support layer.
  • The color view is a simple view with support for a layer that has a background color.
  • Background view is a hosting level that has a sublevel with content installed on the image ( contentCenter ).
  • The content context is a container view with support for < containing one subheading, a custom support layer (not NSButton).
  • The footer view overlaps the scroll view by about 3 pixels.

I get pretty erratic behavior with this layout. Here are three different scenarios that I get that are randomized every time I run the application.

1) Everything looks fine. Background view and all contents:

enter image description here

2) The button looks fine, but the background view seems partially transparent:

enter image description here

3) The background view is displayed correctly, but the button is gone:

enter image description here

There is absolutely no code that changes between each of these scenarios. I just stop and start the application again. I made sure that I did not change anything related to opacity at runtime. The only thing I do at runtime is to set the background and image colors in the views.

EDIT: I had the feeling that overlapping views could cause problems, so I tested without overlapping and got the same results.

EDIT 2: This is apparently a problem with zPosition layer layers supported by views. The order is scrambled and random. If I manually force the zPosition layers to have the correct values ​​according to the order of the look, then everything is fine. Unfortunately, I cannot find a cleaner way to do this than just setting zPosition .

+8
objective-c cocoa core-animation calayer nsview
source share
1 answer

This seems to be an OS X error. A radar has been sent . Meanwhile, here is the best workaround I've found (where view is the supervisor of all the siblings representations):

view.subviews = [view.subviews copy]

Running the installer for subviews sets the correct zPosition at presentation levels.

+2
source share

All Articles