即使内容足够大,NSScrollView也不显示滚动条

发布于 2024-09-07 12:32:24 字数 734 浏览 2 评论 0原文

我有这个类:

标题:

@interface vcMain : NSWindowController {
    IBOutlet NSView *scroll;
}
@property (retain) IBOutlet NSView *scroll;

-(IBAction)test:(id)sender;

@end

来源:

@implementation vcMain

@synthesize scroll;

-(IBAction)test:(id)sender {
    vItem *item = [[vItem alloc] initWithNibName:@"vItem" bundle:nil];
    NSView *view = [item view];
    [view setFrame:NSMakeRect(0, 0, 300, 600)];
    [view setAutoresizingMask:( NSViewHeightSizable) ];
    [scroll addSubview:view];
}

@end

*滚动是窗口内容视图中边框滚动视图中的自定义视图。

vItem 是 ViewController 的子类,上面有一些东西来标识它的位置。

问题:将 vcMain 的大小从默认的 300x600 调整为 150x300 时,我看不到任何滚动条。

我做错了什么?

汤姆

I have this class:

Header:

@interface vcMain : NSWindowController {
    IBOutlet NSView *scroll;
}
@property (retain) IBOutlet NSView *scroll;

-(IBAction)test:(id)sender;

@end

Source:

@implementation vcMain

@synthesize scroll;

-(IBAction)test:(id)sender {
    vItem *item = [[vItem alloc] initWithNibName:@"vItem" bundle:nil];
    NSView *view = [item view];
    [view setFrame:NSMakeRect(0, 0, 300, 600)];
    [view setAutoresizingMask:( NSViewHeightSizable) ];
    [scroll addSubview:view];
}

@end

*scroll is a Custom View in a Bordered Scroll View in the Content View of a Window.

vItem is a ViewController subclass with some things on it to identify its position.

Problem: When resizing my vcMain from the default 300x600 to 150x300, I don't see any scrollbars.

What am I doing wrong?

Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2024-09-14 12:32:24

解决了

,其实很简单。调整视图的大小显然也调整了子视图的大小,因此没有必要显示滚动条 - 但是,由于子视图中的元素没有移动,我没有注意到子视图正在调整大小。

通过更正视图的大小调整来解决。

Solved

It was simple, actually. Resizing the view apparently also resized the subview so it wasn't neccessary to show the scrollbars - however, as the elements in the subview didn't move, I didn't notice that the subview was resizing.

Solved by correcting the resizing of the view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文