-1

When laying out a UIScrollView in Interface Builder I want to be able to configure view that are larger than my screen. Is there a way to visually scroll the content of my UIScrollView within my Storyboard in Interface Builder?

Lukas Spieß
  • 2,478
  • 2
  • 19
  • 24
  • I am pretty sure there has to be another answer. I have already seen a ScrollView scroll in Interface Builder but just can't figure out the steps to reproduce. – Lukas Spieß Jul 23 '14 at 23:42
  • Also, this exakt thing is easily possible with UITableView where you can scroll without problems if you have more cells than fit on the screen. Why not in UIScrollView? – Lukas Spieß Jul 23 '14 at 23:44
  • Because some things just aren't. You can always offset Y of your content view to change what's visible so you can edit it to your likening. I'd be the first to welcome a scrollview I can scroll in IB. – Bernhard Grabowski Jul 23 '14 at 23:49
  • Filing a Radar right now... :) – Lukas Spieß Jul 23 '14 at 23:50
  • It's possible since Xcode 11 — select some view inside scroll view in the View Tree and then scroll with your touchpad. Vote for reopen. – Pavel Alexeev Dec 02 '19 at 17:33

1 Answers1

2

No, you can't scroll it, but you can just give the scroll view a content view and make that content view as large as you need it. Auto layout (or manual configuration) will take care of the actual contentSize at runtime.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Setting the content size is not my problem. How do I design a view that is e.g. 1000pt high and of which only half is visible in IB? – Lukas Spieß Jul 23 '14 at 23:47
  • If the view is 1000 pt high it will be completely visible in IB. Grow the view controller as much as you need to. – matt Jul 23 '14 at 23:51
  • Here is a downloadable example project that demonstrates. The content of the scroll view is considerably taller than an iPhone. https://github.com/mattneub/Programming-iOS-Book-Examples/tree/master/bk2ch07p367scrollViewInNibAutolayout2/ch20p673scrollViewInNib – matt Jul 23 '14 at 23:51
  • Okay, now I get what you're saying. Thanks, very helpful! Would you mind updating your answer with the link and an explanation about actually growing the whole _View Controller_? – Lukas Spieß Jul 24 '14 at 00:00
  • I think this matter has been dealt with sufficiently on Stack Overflow that no more is needed. – matt Jul 24 '14 at 00:47