我在NSWindow
视图中添加了界面构建器的scrollview,并在NSScrollview
中添加了CustomView我在我的
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];
我的AppDelegate.h
IBOutlet NSScrollView * scrollview;
IBOutlet NSView * view;
IBOutlet CustomView *paintingfield;
IBOutlets
属性NSScrollView
与NSScrollView
,NSView
与CustomView,CustomView与CustomView相关联。
调用-awakeFromNib
问题是因为NSScrollView
当我打开图像时,我得到空白窗口而不是打开图像,滚动没有NSScrollView
图像打开正确的任何想法如何解决它?
答案 0 :(得分:0)
尝试更改您的代码:
- (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) ];
}