【发布时间】:2015-09-30 05:11:52
【问题描述】:
我正在使用大小为 440x44 的 NSScrollView,我正在动态创建检查按钮,并希望将它们水平而不是垂直添加到滚动视图中,我最初在滚动视图中添加了 10 个按钮,如下所示
self.scrollView.hasVerticalScroller=NO;
self.scrollView.hasHorizontalScroller=YES;
int counter =0;
for(int i=0;i<10;i++)
{
NSRect frame;
frame.size.width = frame.size.height = 50;
if(i>0)
frame.origin.x=counter;
NSButton *myCheckBox2 = [[NSButton alloc] initWithFrame:frame];
[myCheckBox2 setButtonType:NSSwitchButton];
[myCheckBox2 setTitle:@"Hello"];
[myCheckBox2 setBezelStyle:2];
[self.scrollView.documentView addSubview:myCheckBox2];
//[self.scrollView setDocumentView:myCheckBox2];
[self.scrollView addSubview:myCheckBox2];
counter=counter+50;
// [self.scrollView setHorizontalLineScroll:1000];
}
但问题是我无法水平滚动它......我怎样才能做到这一点?
【问题讨论】:
标签: ios macos nsscrollview