1

I have a screen that doesn't fit into a 3.5 inch phone screen. In iOS 6 I had the contents of the screen in a scroll view, but in iOS 7 that option is constantly grayed out.

Here is the screen shot

enter image description here

Would anyone know how to add the scrolling to my screen in ios 7?

Thank you!

Second screen shot with the scroll view.

enter image description here

Genadinik
  • 18,153
  • 63
  • 185
  • 284

2 Answers2

5

Rather than selecting the entire view controller, you need to have a view selected. The options in Editor -> Embed In are contextual and since you have then entire view controller selected, your only options are to embed the whole VC within a Navigation Controller or a Tab Bar Controller.

If you can't get the right selection by clicking within Interface Builder, try expanding the outline view and selecting your view. Then try to embed your view within a scrollview.

enter image description here

Note that your root view must be a UIView, so you won't be able to embed the root view in a scrollview because that would put a scroll view at the root.

Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
  • thank you! By the way, very naive question, but how can I navigate to the place where I can select all the views in my VC? I can't seem to get there :) – Genadinik Nov 28 '13 at 00:09
  • By "the place where I can select all the views" do you mean the document outline view in the screenshot? In Interface Builder there is an always-present button in the bottom left corner of the storyboard or nib that you can select to show/hide the outline view. With it open, I usually select an element in the VC I'm interested in and quickly scroll up or down in the outline view until I see my selection. – Kyle Clegg Nov 28 '13 at 00:42
  • aaah, thank you, got it! But take a look, I added a screen shot of what I see when I expanded that view. There is already a scroll view there!! Would you know why the might not scroll? – Genadinik Nov 28 '13 at 01:17
  • Could be a number of issues preventing the scrollview from scrolling. Try checking out http://www.g8production.com/post/57513133020/auto-layout-with-uiscrollview-how-to-use for some tips on using auto-layout and scrollviews together. – Kyle Clegg Nov 28 '13 at 06:58
  • thank you - your mention of auto-layout reminded me to try to turn it off, and then things worked. I am still not sure if it is worth using autolayout. Do you have thoughts on that? – Genadinik Nov 30 '13 at 17:08
  • Long-term maintainability and the ability to dynamically handle various screen sizes are two big reasons Apple's beefed up the auto-layout tools so much with Xcode 5. What's best depends on your intended use, experience, and timeline, but if you're in for the long haul using auto-layout is definitely a great solution. – Kyle Clegg Dec 01 '13 at 07:22
2

Three problems I ran into that I hope can help:

1) Make sure "Safe Area", or other object that shouldn't be there, isn't one of the objects selected in your view while trying to embed. For a simple test select just one simple object like a textfield or label and see if the Editor -> Embed In is still greyed out and work backwards if you have to.

2) You're going from View > Content to View > ScrollView > View > Content. So after embedding in a scrollview, embed in a view.

3) Once embedded make sure your scrollview is less than your content size, or it won't scroll: https://stackoverflow.com/a/28146729/1323357

BriOnH
  • 945
  • 7
  • 18