简体   繁体   English

iOS:能不能在IB下设置一个ScrollView?

[英]iOS: Can you set up a ScrollView under IB?

Can't seem to find a good tutorial for ScrollView so I've been trying to set it up myself using IB - is this even possible?似乎找不到 ScrollView 的好教程,所以我一直在尝试使用 IB 自己设置它 - 这甚至可能吗?

I've added a scrollview to a ViewController, sized it to 640x200, added a view at the same size with 2 labels at each end.我向 ViewController 添加了一个滚动视图,将其调整为 640x200,添加了一个相同大小的视图,每端有 2 个标签。 Created an outlet and linked it up to Files Owner, but when I run I see the first label but it won't scroll.创建了一个出口并将其链接到文件所有者,但是当我运行时,我看到了第一个 label 但它不会滚动。 Basically I'm trying to create a half-height horizontal scroller to show a number of buttons, but I can't even get it moving.基本上我正在尝试创建一个半高水平滚动条来显示许多按钮,但我什至无法让它移动。

Little help?一点帮助?

Thanks谢谢

I´ve never managed to get desired results for the scroll view using IB.我从来没有设法使用 IB 为滚动视图获得所需的结果。 These two lines always do the trick:这两行总是有用的:

   [mainScrollView setFrame:CGRectMake(0, 0, 320, 700)];
  [mainScrollView setContentSize:CGSizeMake(320,1200)];

As far as I know there is no way to set the contentSize in IB.据我所知,无法在 IB 中设置contentSize So set it in viewDidLoad method of your view controller.所以在你的视图 controller 的viewDidLoad方法中设置它。

[myScrollView setContentSize:CGSizeMake(640,200)];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM