From 1f7dde75e2d7a9d217c302bdaff320fd2c4d9c76 Mon Sep 17 00:00:00 2001 From: Drew Olbrich Date: Sat, 9 Feb 2019 11:40:22 -0800 Subject: [PATCH] Wrap all images in div tags so aspect ratios are correct on mobile --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4e61856..57e559d 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,7 @@ A common UIKit Auto Layout task involves creating a view controller with a fixed For example, consider this sign up screen, which fits iPhone Xs, but not iPhone SE with a keyboard: -
- -
+
This case can be handled by nesting the view inside a scroll view. You can do this manually in Interface Builder, as described by Apple's [Working with Scroll Views](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithScrollViews.html) documentation, but many steps are required. If your view contains text fields, you'll have to write code to compensate for the keyboard when it's presented, as in [Managing the Keyboard](https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-SW3). However, handling the keyboard robustly is [surprisingly complicated](#keyboard-resize-filtering), especially if your app presents a sequence of screens with keyboards in the context of a navigation controller, or when device orientation support is required. @@ -79,7 +77,7 @@ To configure `ScrollingContentViewController` in a storyboard: 2. In Interface Builder's outline view, control-click your view controller and connect its [`contentView`](#contentView) outlet to your view controller's root view. - +
3. If your view controller defines a [`viewDidLoad`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621495-viewdidload) method, call `super.viewDidLoad` if you aren't already doing so. @@ -137,7 +135,7 @@ To determine the size of the scroll view's content size, ScrollingContentViewCon If the size of your view controller is intentionally highly constrained (e.g. consisting exclusively of constraints with `required` priority and lacking [`greaterThanOrEqual`](https://developer.apple.com/documentation/uikit/nslayoutconstraint/relation/greaterthanorequal) relation constraints), you may see Auto Layout constraint errors in Interface Builder if the constraints don't match the simulated size of the view, for example, when you switch between simulated device sizes. The easiest way to resolve this issue is to reduce the priority of one of your constraints. The value 240 is a good choice because it is lower than the default content hugging priority (250) and consequently, it will help avoid the undesirable behavior where text fields and labels without height constraints stretch vertically. - +
### Intrinsic Content Size @@ -149,7 +147,7 @@ The default `UIView` content hugging priority is [`defaultLow`](https://develope The content view is positioned within the scroll view's safe area. Consequently, the content view's background color won't extend underneath the status bar, home indicator, navigation bar, or toolbar. - +
To specify a background color that extends to the edges of the screen: @@ -182,7 +180,7 @@ UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSp In Interface Builder, it's possible to design a view controller that is intentionally larger than the height of the screen. To do this, change the view controller's simulated size to Freeform and adjust its height. When used with ScrollingContentViewController, the view controller's oversized content view will scroll freely, assuming its constraints require it to be larger than the screen. - +
## Usage Without Subclassing @@ -366,7 +364,7 @@ The optional `margin` parameter specifies an extra margin around the first respo ScrollingContentViewController inserts a scroll view between the content view and its superview, using Auto Layout to constrain the scroll view's content layout guide to the size of the content view. The content view's size is also constrained to be greater than or equal to the size of the scroll view's safe area, so it can utilize the full area of the screen assigned to the scroll view. - +
When the content view is first assigned, if it has a superview, the scroll view replaces it in the view hierarchy and all of the superview's constraints that reference the content view are retargeted to the content view. The content view's width and height constraints and autoresizing mask are transferred to the scroll view.