Adding items to an UIScrollView with Interface Builder?

Discussion in 'iOS Programming' started by Xino, Sep 17, 2008.

  1. Xino macrumors member

    Joined:
    Sep 5, 2008
    #1
    I've created an UIView and renamed the class to UIScrollView. This is the code for making the UIView bigger then te screen:

    Code:
    settingsUIScrollView.contentSize = CGSizeMake(320,600);
    
    Everything works so far but I want to add a lot of elements to that view. The problem is I can't add them with Interface Builder because I can't reach the space outside the window. In other words, I'm unable to scroll in Interface Builder and therefor unable to add more elements.

    When I've created some elements (UIButton, UILabel, etc.) and I select all of them and drag them to somewhere below the window and executed the application, I'm able to scroll and see those elements but can't reach them anymore in Interface Builder...

    I don't want to add all of those buttons, labels, etc. via code.

    How to solve this problem?
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    I haven't done this but you can set the height of a view to be 600 in IB. Maybe you need to set the size in IB to 600 temporarily, do your layout, then set it back to 460.
     
  3. Xino thread starter macrumors member

    Joined:
    Sep 5, 2008
    #3
    And can you tell me how to do that? I don't see an option to set the size of the window?
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Select the view in the xib window. In the Inspector window click on the little ruler on the top. It should say Frame in the popup. In the box marked H enter the height you want. Click return.

    This pane is also called the Size Inspector in the menu bar.
     
  5. Xino thread starter macrumors member

    Joined:
    Sep 5, 2008
    #5
    Hm I can change the height of the UIScrollView but I'm still unable to "scroll" down the UIScrollView in Interface Builder to drag and move objects such as UILabel, UIButton, etc. to the view...

    The problem is I can't reach the space above or below to style the view..

    I hope you can help me out with this one..
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    You may want to look at the PageController sample code. It seems to be the only one that has a UIScrollView.

    I don't understand what you mean by this. If you resize the scrollview in IB to be large then you should see a window with the title Scroll View that is as large as the size you've set. Just drop labels and whatever into that window and drag them to whatever position you want.

    Make sure you set the View Mode to lines in the xib window. If you double-click on Scroll View in that window do you see the new Scroll View window appear?
     

Share This Page