SubClassed NSView does not appear in user view

I subclassed NSView and I added it to another view as follows:

 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 is not displayed. This is visible when resizing the window. Note. I am using a transparent window.

+4
source share
3 answers

So you are using a transparent view, it was not visible to others. Create a full-size window and create your own objects and display instead the increase in the width of the halls.

+1
source

Without seeing more code, it's hard to say what is happening. There are some tips in this thread that can help you: fooobar.com/questions/58039 / ...

Maybe you are not calling this from the main thread? Does your view have a custom implementation of drawRect: :? Could you put a breakpoint there to see what size the missing rectangle has? Right size?

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

Without seeing more code, it is difficult to identify the problem.

+1
source

Source: https://habr.com/ru/post/1491627/


All Articles