As soon as I embed my custom NSView in a scroll view, nothing is drawn in my custom view.
To replicate the issue, I created a vanilla Cocoa app. I subclassed NSView, and its drawRect
handler, I do something simple like a red fillRect
. I verify 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 menu Editor > Embed In > Scroll View.
There is no longer a red rectangle in my view. I've verified that my drawRect
is no longer being called.
What gives?
I thought I'd come across a solution here, but it was of no help.
Seems so simple.
Running Xcode 5.0.2 & OS10.9.1.
Fixed... I had to add something like this to my custom view:
- (NSSize)intrinsicContentSize
{
return NSMakeSize(960,540);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With