4

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.

6
  • Your view might need a layer... Commented Nov 11, 2013 at 8:18
  • 1
    show more of HolderView and of customView... what did you override / whats your init or drawRect Commented Nov 11, 2013 at 8:29
  • 1
    also pay heed to naming: Don't start variable names with a capital letter Commented Nov 11, 2013 at 8:30
  • what is the frame on your container view. you might be getting clipped Commented Nov 11, 2013 at 10:07
  • i created a container view for the width of customView. Initially i displayed only one customView. If the user clicks a button then increases the customView width and container view width. But the CustomView was not shown untill any user interations occured in window. Commented Nov 11, 2013 at 10:11

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1
+200

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.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.