NSText的水平滚动条

伊戈尔

全部,

我正在查看文档,但对我来说尚不清楚:

要设置水平和垂直滚动条,请使用清单4中的语句代替之前清单中的相应语句。

但是,它没有说需要替换哪个块(或代码)。

有人可以给我一些启示吗?

我正在寻找一种显示NSTextView的水平滚动条的方法。

迈克尔·道特曼

Apple文档的编写方式不会使非英语母语的人容易理解。

该文档的意思是,除了清单1 2和3中的代码外,还用清单4中的内容替换了先前清单中类似(或“对应”)的行。

换句话说,合并清单1、2、3,然后覆盖清单4中的内容,结果应该是这样的:

NSScrollView *scrollview = [[NSScrollView alloc] initWithFrame:[[theWindow contentView] frame]];

NSSize contentSize = [scrollview contentSize];

[scrollview setBorderType:NSNoBorder];

[scrollview setHasVerticalScroller:YES];

[scrollview setHasHorizontalScroller:YES];

[scrollview setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];

theTextView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)];

[theTextView setMinSize:NSMakeSize(0.0, contentSize.height)];

[theTextView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];

[theTextView setVerticallyResizable:YES];

[theTextView setHorizontallyResizable:YES];

[theTextView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];

[[theTextView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];

[[theTextView textContainer] setWidthTracksTextView:NO];

[scrollview setDocumentView:theTextView];

[theWindow setContentView:scrollview];

[theWindow makeKeyAndOrderFront:nil];

[theWindow makeFirstResponder:theTextView];

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章