Dave
Dave

Reputation: 493

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?

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. Created an outlet and linked it up to Files Owner, but when I run I see the first label but it won't scroll. 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

Upvotes: 0

Views: 257

Answers (2)

Mobile Developer
Mobile Developer

Reputation: 5760

I´ve never managed to get desired results for the scroll view using IB. These two lines always do the trick:

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

Upvotes: 2

jamapag
jamapag

Reputation: 9318

As far as I know there is no way to set the contentSize in IB. So set it in viewDidLoad method of your view controller.

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

Upvotes: 0

Related Questions