niko
niko

Reputation: 33

iOS - Change size of view in Interface Builder for putting into scrollview

Here is my problem:

I want to create a view whose height exceeds the height of the iPhone-screen. To deal with that, I am using a UIScrollView which works just fine. I created the scroll view in interface builder and set the content size programmatically to twice the height of the screen (that's enough for my purpose). I can run the code and it works just fine. I can scroll up an down without trouble.

The only thing I don't get is how I can add more items (buttons, labels etc.) to the view in interface builder, since it doesn't allow me to change the size of the view. I was thinking to create a scroll view as a top level object and then place a view (the contentview) of a larger height into it. Now the only thing to do is add all the items to the contentview, which is not possible because in interface builder the contentview has only its regular size.

I am thankful for any thoughts on this :-)

Upvotes: 0

Views: 2012

Answers (3)

neverbendeasy
neverbendeasy

Reputation: 988

The accepted answer is accurate but no longer complete for iOS7 and XCode5. Check out @Whasssaaahhh answer here for more detail.

You can drag items on top of the view in two ways.

1) Change Y-Position: If you select your UIView and in Size Inspector change its Y position to whatever section of the view you want to see (try something like -100 to go down or 100 to go up, play around with whatever numbers work for your screen size) you can drag all your buttons, labels, text fields however you like for each visible section.

2) Drag With Mouse: If you carefully select just the UIView with your mouse and carefully drag it either upwards or downwards and let go, it will snap to the new position so you can edit it. It's easier to "see" this if you drag some objects on it first.

Upvotes: 1

Saurabh Singh
Saurabh Singh

Reputation: 247

You can change the size of your view and size of your scrollview along with the addition of objects. add the added object height to the scrollView.contentSize and also add into the height of the view.

Upvotes: 0

Yashesh
Yashesh

Reputation: 1752

You can change the size of your UIView from the interface builder.

For that you have to go to Interface Builder of particular UIView. From Simulated Metrics *select Size = Freeform* and now you are able to change the size of UIView from interface builder.

Upvotes: 2

Related Questions