Macos 在NSTextView上滚动不起作用
我在屏幕上的NSTextView上添加了一些文本,因此我希望用户能够在视图中滚动查看整个日志。但是我不能让我的文本视图滚动。下面是我的代码。你知道这里出了什么问题吗Macos 在NSTextView上滚动不起作用,macos,cocoa,nstextview,nsscrollview,Macos,Cocoa,Nstextview,Nsscrollview,我在屏幕上的NSTextView上添加了一些文本,因此我希望用户能够在视图中滚动查看整个日志。但是我不能让我的文本视图滚动。下面是我的代码。你知道这里出了什么问题吗 NSView *superview = [window contentView]; NSRect scrollViewFrame = NSMakeRect(10, self.window.frame.size.height / 2 - 200, 400, 400); NSScrollView *scrollview = [[NSS
NSView *superview = [window contentView];
NSRect scrollViewFrame = NSMakeRect(10, self.window.frame.size.height / 2 - 200, 400, 400);
NSScrollView *scrollview = [[NSScrollView alloc]
initWithFrame:scrollViewFrame];
NSSize contentSize = [scrollview contentSize];
[scrollview setBorderType:NSLineBorder];
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:NO];
[scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
NSRect textViewFrame = NSMakeRect(0, 0, contentSize.width, contentSize.height);
self.logTextView = [[NSTextView alloc] initWithFrame:textViewFrame];
[self.logTextView setMinSize:NSMakeSize(0.0, contentSize.height)];
[self.logTextView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[self.logTextView setVerticallyResizable:YES];
[self.logTextView setHorizontallyResizable:NO];
[self.logTextView setAutoresizingMask:NSViewWidthSizable];
[scrollview addSubview:self.logTextView];
[superview addSubview:scrollview];
这是固定的。我忘了为scrollview设置文档视图
[scrollview setDocumentView:self.logTextView];