Friday, August 30, 2013

Creating a Simple ScrollView in iOS

I hate that I keep finding too-complicated tutorials for a very simple scrollview.  Here's what I did today that I must forever keep recorded for my reference.

1. Create your view.
2. Make your viewcontroller use the delegate for UIScrollView.  This is something like

@interface YourViewController : UIViewController <UIScrollViewDelegate>

3.  In interface builder, right-click your ScrollView (not the file owner) and hook the delegate property up to File's Owner.  This involves drag-and-dropping from the circle next to "delegate" that shows up in the drop-down when you right click the scroll view.

4. Click the "Show the Size inspector" tab (it looks like a ruler and is next to a bunch of cutesy icons like a paper, squiggly lines in a dark box, a newspaper, a belt, and an arrow).  Under Scroll View Size -> Content Insets, set the "Bottom" field to a number larger than your current size.  This change makes it so the user can scroll to that size.

The other fields for "Content Insets" would probably have the same impact when changed, I imagine.

I am not a fan of Apple.