Question

I have an existing view with several elements, I was thinking of how to include a scrollview to contain all the existing elements without having to go through redesigning one by one the elements,

My objective is, that when my orientation changes to landscape, the elements behind can be scrollable specially when a keyboard is currently displayed.

Can this be done manually or programmatically, and how? Or is there any best approach for this type of scenario's?

*Edit (for clarity)

My apologies for the lack of clarity with the initial question;

I have a view with 3 Textfield, A button and 2 switch, Initially my app only supported the "Portrait" orientation, however, recently I have decided to add "Landscape" orientation support, I already did this. Now my problem is when I'm on landscape the view elements gets covered by the keyboard (specifically). So I was thinking if I could include a scrollview and put the views existing elements(objects) without having to re-design the nib, what I have done already;

I drag a scrollview into the view then making all the existing elements as children of the scrollview so the hierarchy looks like;

--view
  --scrollview
    --textfield
    --button

The end product I get with this approach is that all the elements stacks on top of the other, so I've lost my original design.

So this is what Im asking, is there anyway, to add a scrollview without having to go through the design phase again.

TIA

Was it helpful?

Solution

If your view is designed in a nib, from IB you can select all the elements of the view and then go to Editor->Embed in->Scroll View from the menu.

OTHER TIPS

Following are the steps-

 1.Add the scrollview to the main view as subview.
 2.create a new view which contains all your elements for the scrollview.
 3.add the new view to the scrollview as subview.
 4.set the content size of the scrollview as the size of the new view.

Change the frame of the newView accordingly on orientation and repeat step 4.

Thats all you need to do..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top