Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>UPDATE</h3> <p>I have posted <a href="https://stackoverflow.com/a/16889377/77567">another solution here</a> which I think is simpler and better, and works in storyboards.</p> <h3>ORIGINAL</h3> <p>Create your scroll view in the nib with the appropriate superview, position, and size.</p> <p>Next, create a <em>completely separate, top-level</em> <code>UIView</code> instance by dragging a <code>UIView</code> 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:</p> <p><a href="https://i.stack.imgur.com/2VakY.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2VakY.gif" alt="setting up content view"></a></p> <p>This new top-level view will be your content view. Give your view controller two outlets: <code>scrollView</code> and <code>contentView</code>:</p> <pre><code>@interface MyViewController @property (nonatomic, weak) IBOutlet UIScrollView *scrollView; @property (nonatomic, strong) IBOutlet UIView *contentView; @end </code></pre> <p>In the nib, wire up the <code>scrollView</code> outlet to the scroll view and wire up the <code>contentView</code> outlet to the content view.</p> <p>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).</p> <p>In your view controller's <code>viewDidLoad</code>, add <code>contentView</code> as a subview of <code>scrollView</code> and set <code>scrollView.contentSize</code> to the size of <code>contentView</code>:</p> <pre><code>@implementation MyViewController @synthesize scrollView = _scrollView; @synthesize contentView = _contentView; - (void)viewDidLoad { [super viewDidLoad]; [self configureScrollView]; } - (void)configureScrollView { CGSize size = self.contentView.bounds.size; self.contentView.frame = CGRectMake(0, 0, size.width, size.height); [self.scrollView addSubview:self.contentView]; self.scrollView.contentSize = size; // If you don't use self.contentView anywhere else, clear it here. self.contentView = nil; // If you use it elsewhere, clear it in `dealloc` and `viewDidUnload`. } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload