Muruganandham K
Muruganandham K

Reputation: 5331

subClassed NSView not appearing in a Custom View

I have subclassed NSView and I added it to another view like this:

clockT = [[CustomView alloc]initWithFrame:NSMakeRect(0, 0, 156, 155)]; 
[holderView addSubview:clockT];   
[clockT setNeedsDisplay:YES];
clockT.tZone = @"Canada/Yukon";  

The view was created and added to holderView but not visible. It is visible during resizing the Window. Note: I am using a transparent Window.

Upvotes: 4

Views: 674

Answers (3)

Johannes Fahrenkrug
Johannes Fahrenkrug

Reputation: 44846

Without seeing more code, it is hard to tell what's going on. This thread has some advice that might help you: https://stackoverflow.com/a/1503828/171933

Could it be that you are not calling this from the main thread? Does your view have a custom drawRect: implementation? Could you put a breakpoint there to see what size the passed-in rect has? Is it the right size?

What if you just create a vanilla NSView with, say, a green background color and add that to your holder view? Does that work? If so, something is wrong with the implementation of your CustomView.

Without seeing more code it is hard to pinpoint the problem.

Upvotes: 1

Laurent Etiemble
Laurent Etiemble

Reputation: 27929

There is a sample application on the Apple Developer Site that may help you with that. This sample demonstrates how to create windows with custom shapes, no title bar, and transparent content.

Upvotes: 2

Muruganandham K
Muruganandham K

Reputation: 5331

So, you are using transparent view, It was not visible to others. Create the window with full size and create your objects and display instead to increasing holderview width.

Upvotes: 1

Related Questions