I have a scrollview which has to display a view larger than the available display area. I want to easily design the user interface without moving the embedded view up and down every time I have to do some changes. The problem is everything outside the visible area is invisible in IB.
Is there any switch or trick to make everything visible in IB?
UPDATE
I have posted another solution here which I think is simpler and better, and works in storyboards.
ORIGINAL
Create your scroll view in the nib with the appropriate superview, position, and size.
Next, create a completely separate, top-level
UIView
instance by dragging aUIView
out of the palette and dropping it into the work area outside of any existing views. In the Attributes inspector, set the Size popup to “None” and make sure the Status Bar, Top Bar, and Bottom Bar are all set to None. Here's an example:This new top-level view will be your content view. Give your view controller two outlets:
scrollView
andcontentView
:In the nib, wire up the
scrollView
outlet to the scroll view and wire up thecontentView
outlet to the content view.Build your content view hierarchy inside the content view. Set its size as large as you need - it can be larger than 320x480 (as long as you have set all of its bars to None).
In your view controller's
viewDidLoad
, addcontentView
as a subview ofscrollView
and setscrollView.contentSize
to the size ofcontentView
: