views:

238

answers:

1

Hi, all!

I imagine this is pretty dead-simple, but somehow I haven’t been able to get it to work:

I need to display a View containing a group of controls (roughly 800px tall) -- which can be scrolled vertically by the user, as that view is too big to fit on the screen all at once.

That’s it.

I’d think that this might mean something like this:

UIView [normal size] > UIScrollView > UIView [the oversized one]
... and then enabling vertical scrolling, etc.

But somehow I'm missing something, as the best I've gotten is the first screenful to appear on-screen, without the ability to scroll down.

~~~

[Note: I know that this might often be done using a Table view, and vertical scrolling then happens for ‘free’. But this is a series of special-purpose controls (an odd assortment of various UISliders, UISwitches, UILabels, UIButtons, etc.) that wouldn’t readily fit into a standard table view without a bunch of customizing anyway. They’re also static as well (i.e., don’t need to be changed programatically) -- hence they can be completely built in IB, and that’s how I’d much prefer to do it for this situation anyway. I just need to allow the whole lot to be accessible via scrolling.

I also know that they could be split up into multiple screens, and I'll do this if absolutely necessary; but they're a unified logical group, and so that's not the optimal choice in this instance.]

Any suggestions? That (and/or a code fragment) would be VERY much appreciated.

Many thanks in advance!

+2  A: 

My initial thought is... have you tried:

    [scrollView setContentSize:CGSizeMake( scrollWidth, scrollHeight)];

My secondary thought is the UIScrollView may not be receiving the scroll commands as you are really scrolling on a UIView, and not the UIScrollView directly... You might need to do some subClassing to get this operational, but I'm afraid that's a bit beyond me as I am still a beginner. :)

My tertiary thought is - why are you adding a UIView to the UIScrollView rather than adding the controls directly to the UIScrollView?

Dutchie432
Agreed, you have to set the set the content view size. A table view IS a scroll view, you also get the scrollview scolling for free.
Corey Floyd
Wow, you guys are awesome! :)Yes, this was the key ingredient (I guess there’s no way to set Content view dimensions within IB, and that’s why it’s tripped a lot of people up).[Also see http://www.lyingonthecovers.net/?p=366 -- but it turns out all I really needed, Dutchie432, was your one line of code.]Your ‘tertiary’ thought was also very helpful ... I think the reason I’d gone that route was so that I could see their entire layout on the screen at the same time.In any event, this is certainly enough to do the trick for now.Thank you so much for your fast response! :))