Nikolai Nagornyi
Nikolai Nagornyi

Reputation: 1461

Custom interface object invisible after switching between tabs

My app has a preferences window with a toolbar. Its preferences tab is a separate NSView object. When I put standard buttons, boxes, etc. in each view, switching between tabs work wonderfully, but when I add custom boxes or views, the custom objects become invisible after switching between tabs.

How do I fix this?

Notice that I use method drawLayer: in each custom object. I mark the "layer" checkbox in IB for the superview.

Upvotes: 0

Views: 117

Answers (1)

Rob Keniger
Rob Keniger

Reputation: 46028

You shoudn't use the implicit layer on a layer-backed view to do custom drawing. Although this sometimes works, it is not supported.

Instead, you should create your own CALayer object and add it to the view's implicit layer using [self.layer addSublayer:yourCustomLayer]. You would then set your object as the layer's delegate and implement drawLayer:inContext: to do your custom drawing.

Upvotes: 0

Related Questions