views:

3346

answers:

1

While I've used UIScrollView successfully in the past by manipulating it programmatically, I'm having trouble getting it to work by setting it up exclusively in Interface Builder.

I have a simple "about" page in my iPhone app. It has a UITextView, some icons, and links to my other apps. I have added all of these views to my UIScrollView, arranging them so that their total size is > 480. When I launch my app, the scrollview displays only the contents that fit on the screen, and nothing scrolls.

Is it possible to do this entirely via IB, or must I manipulate the contentSize via code?

+18  A: 

You forgot to set the contentSize property of the UIScrollView. Strangely enough you can not do this from Interface Builder. You will have to do it from the view controller managing this scroll view.

St3fan
That's right. It always seemed strange to me why they didn't add this capability to IB.
Marco Mustapic
Wow, kind of makes IB rather, pointless... This did the trick, thanks.
Caffeine Coma
You could make a subclass of UIScrollvView that checks if there is just one subview at (0,0) and then automatically sets the contentSize based on that subview.
St3fan
+1 to St3fan's suggestion
Mike Akers
That's the best piece of advice I've received in a while. I could not figure out why my scroll view didn't work, and didn't find that info about contentSize anywhere else. Thanks.
Drew C
nice...just lost an hour to that little gem.
Gareth Davis