Eight of the 20 buttons are to show. But I can't scroll through the rest? Is a scroll bar supposed to show?
NSScrollView *nssvFonts = [[NSScrollView alloc] initWithFrame:CGRectMake(200, 200, 200, 400)];
[self.view addSubview:nssvFonts];
[nssvFonts.documentView setFrame: NSMakeRect(0,0,200, 400) ];
nssvFonts.hasVerticalScroller = YES;
for(int i = 0; i < 20; i++){
NSButton *btnDown = [[NSButton alloc] initWithFrame:CGRectMake(0, 50 * i, 200, 50)];
[nssvFonts addSubview:btnDown];
[btnDown setButtonType:NSMomentaryPushInButton];
[btnDown setTitle:[NSString stringWithFormat:@"Down: %d", i]];
}
So I applied Willeke's advice and made the addition and changes:
NSScrollView *nssvFonts = [[NSScrollView alloc] initWithFrame:CGRectMake(200, 200, 300, 400)];
[self.view addSubview:nssvFonts];
[nssvFonts.documentView setFrame: NSMakeRect(0,0,200, 1000)];
//[nssvFonts.contentView setFrame:NSMakeRect(0, 0, 200, 400)];
nssvFonts.hasVerticalScroller = YES;
for(int i = 0; i < 20; i++){
NSButton *btnDown = [[NSButton alloc] initWithFrame:CGRectMake(50, 50 * i, 200, 50)];
[nssvFonts addSubview:btnDown];
[btnDown setButtonType:NSMomentaryPushInButton];
[btnDown setTitle:[NSString stringWithFormat:@"Down: %d", i]];
}
But still no vertical scroll bar is showing and I can't use the mouse to scroll through it either... 1 button down or 2 buttons down to help either.