I have scrollview added with interface builder its implemented in NSWindow
view and in NSScrollview
i added CustomView i'm using this code line in my
AppDelegate.m
- (void)awakeFromNib
id docView = paintingfield;
id viewas = [[NSScrollView alloc] initWithFrame:
[[scrollview contentView] frame]];
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:YES];
[scrollview setBorderType:NSNoBorder];
[scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[scrollview setDocumentView:docView];
[scrollview setContentView:viewas];
an in my AppDelegate.h
IBOutlet NSScrollView * scrollview;
IBOutlet NSView * view;
IBOutlet CustomView *paintingfield;
IBOutlets
are linked propertly NSScrollView
to NSScrollView
, NSView
to CustomView, CustomView to CustomView.
-awakeFromNib
is called
the problem is because of NSScrollView
when i open image i get blank window instead of opened image with scroll without NSScrollView
image opens proper too any ideas how can i fix it?
Try change you code like this:
- (void)awakeFromNib
{
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:YES];
[scrollview setBorderType:NSNoBorder];
[scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[scrollview setDocumentView:paintingfield];
[scrollView.documentView setFrame: CGRectMake(0, 0, paintingfield.frame.size.width,paintingfield.frame.size.height) ];
}