[Tips]UIScrollView + Storyboard + AutoLayout

Doesn’t work UIScrollView?
How to use UIScrollView in Storyboard with AutoLayout.

Storyboard

1.Change “Size” Property of ViewController to “Freeform”.
scrollview_01

2.Set ViewController’s width(or height) to Contents Size(eg:640)
scrollview_02

3.ViewController’s parts are given bellow. Two UITableViews in ScrollView。
scrollview_03

Looks double width.
scrollview_04

4.Relation to ViewController(your filename)
scrollview_05

Code

5. ViewController.h
//UIScrollview’s name is SclView.
@property (weak, nonatomic) IBOutlet UIScrollView *SclView;

6.ViewController.m
Set sizes at viewDidLayoutSubviews.
– (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];

//Set Contentsize(Same size, set at No2. eg:640)
[self.SclView setContentSize: CGSizeMake(640.0, 420)];
//Set the Size of ScrollView( Contentsize > ScrollView’s Size)
self.ScrollContainer.frame = CGRectMake(self.ScrollContainer.frame.origin.x, self.ScrollContainer.frame.origin.y, 320, 420);
}

So build it and Run !