Builder NSScrollView interface does not work with specific IB

I defined a custom class with drawRect called Drawing. I set out the view in my NIB to contain an NSScrollView with the Drawing subzone. When I run the program, the screen is blank. Interestingly, when I create a documentView for an NSScrollView programmatically, I get the image in my scroll view. When I use an instance for nib in my setDocumentView, I get nothing.

So, if the drawing view is set to IB,

[_scrollViewWorkspace setDocumentView:_drawing]; //does not work.

But

[_scrollViewWorkspace setDocumentView:[[Drawing alloc] initWithFrame:NSMakeRect(0,0,[[_scrollViewWorkspace documentView ]bounds].size.width, [[_scrollViewWorkspace documentView] bounds ].size.height)]];

It works great!

Why can't I statically bind a drawing object in a NIB?

+1
source share
2 answers

NSView nib , initWithCoder:, initWithFrame:.

, , Drawing:

- (id)initWithCoder:(NSCoder *)coder {
   NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
   return [super initWithCoder:coder];
}

, [Drawing initWithCoder:] .

initWithFrame: Drawing (, ), initWithCoder:, :

- (id)initWithCoder:(NSCoder *)coder {
   if ((self = [super initWithCoder:coder])) {
      // do custom initialization here

   }
   return self;
}
0

!

Interface Builder, NSScrollView . , Embed- > Scroll View, .

0

All Articles