How to make a UIScrollView using Auto Layout

From the official document :

UIView: Position with constraints.
UIScrollView: Bind to UIView with constraints.
UIDetailView: Set size (intrinsic content size), max out compression-resistance, set top-, bottom-, leading- and trailing constraints to UIScrollView to 0 manually.

Now let’s set up the outlet as the image.

螢幕快照 2014-04-18 下午6.53.10

Next, select Scroll View and in the option menu : Editor -> Resolve Auto Layout Issues -> Add Missing Constraints

Select View under Scroll View in the Size Inspector, make its height as your desire.

And select View and in the option menu : Editor -> Resolve Auto Layout Issues -> Add Missing Constraints

螢幕快照 2014-04-18 下午7.19.30

Now we do some changes.

1. add Width 320 ( Editor ->Pin -> Width)

2. delete Center X alignment

3. Open Vertical Space – (-480) – Scroll View – View in Attributes Inspector

Set Constant : zero

Now the outlet will look like..

螢幕快照 2014-04-18 下午7.07.35

 

Then your ScrollView can be scrolled !

Finished !

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s