Create long scrolling page of controls in IB?

Discussion in 'iOS Programming' started by MarcVanH, Sep 22, 2008.

  1. MarcVanH macrumors newbie

    Sep 12, 2008
    I am trying to create a "settings" page - the single page kind that is really long and scrollable.

    I know I can do this with a Table view (like in UICatalog), but since I just need a single page of controls, I was hoping to do it without all the complexities of a table view.

    Can anyone tell me how to create a long, scrollable view, that I can throw like 20 buttons and sliders on, in interface Builder?
  2. tsornin macrumors newbie

    Jul 23, 2002
    You could use UIScrollView ... in IB just start with a view object and change its parent in the inspector. You can then set the height of the view to larger than the actual iphone window, and add whatever controls you need in the bigger view window.

    I'm messing around with something similar, although one problem I haven't sorted out yet is how to deal with several scrolling UITextViews on top of a scrollview. When I test it in the simulator, it scrolls the first text view, rather than the entire scrollview.
  3. MarcVanH thread starter macrumors newbie

    Sep 12, 2008
    I played with UIScrollView for hours with no luck. Gave up assuming it was just for images, etc.

    Can you walk me through it a bit more specifically?
  4. tsornin macrumors newbie

    Jul 23, 2002
    In interface builder, create a new->view. Click on the view object, and open the inspector window. Look under view identity and change the class identity to "UIScrollView". Then go to the size tab (in the inspector) and change the height from 480 to 600 (or whatever).

    Then you can click on your scroll view object to bring up the view window, and drag whatever controls you want from the IB library into the view.

    Of course you'll still have to set up the appropriate IBOutlet variables and IBAction methods for all your controls (and possibly some delegate methods, depending on what controls you add) in the view controller.

    Only caveat is there doesn't seem to be any way to scroll the scroll view in interface builder itself, so I guess your scrollview is pretty much limited to the height of your screen. If you wanted a longer view you'd probably have to do it all programmatically, rather than using interface builder...
  5. MarcVanH thread starter macrumors newbie

    Sep 12, 2008
    I swear I tried that a few times, but I'll give it another go. Thanks!
  6. MarcVanH thread starter macrumors newbie

    Sep 12, 2008
    Still no luck. I can make the view, change its class, make it's height real tall, and add controls no problem. But when I display it, no scrolling.

    How are you displaying the view? With some kind of controller?
  7. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    There's no need to first create a UIView and then change its class to UIScrollView. Just use the UIScrollView from the catalog.

    I've attached an example project. The one line that's required sets the content size for the scrollview. The rest is done in IB.

    Attached Files:

  8. MarcVanH thread starter macrumors newbie

    Sep 12, 2008
  9. indiekiduk macrumors 6502

    Jul 26, 2005
    Glasgow, Scotland
    [scrollView flashScrollIndicators];
    This should be in viewDidAppear

Share This Page