Simple implementation of custom NSView in NSScrollView kills it

As soon as I embed my custom NSView in the scroll, nothing is drawn in my custom view.

To replicate the problem, I created a vanilla Cocoa application. I have subclassed NSView and its handler drawRect; I am doing something as simple as red fillRect. I verify that this works as expected:

- (void)drawRect:(NSRect)dirtyRect
{
    [super drawRect:dirtyRect];

    [[NSColor redColor] set];
    [NSBezierPath fillRect:dirtyRect];
    // Drawing code here.
}

Back to IB, I click on my custom view, then go to the Editor> Paste> Scroll> menu .

Now I do not have a red rectangle. I checked that mine is drawRectno longer being called.

What gives?

It seemed to me that I found a solution here , but it did not help.

It seems so simple.

Xcode 5.0.2 OS10.9.1.

+4
2

... - :

- (NSSize)intrinsicContentSize
{
    return NSMakeSize(960,540);
}
+5

xcode 6 beta4 (10.9.4) Swift ( adhoc)

func intrinsicContentSize() ->NSSize {
    return NSMakeSize(2000,2000)
}
+2

All Articles