Skip to content

Instantly share code, notes, and snippets.

@mwrites
Created August 15, 2016 04:42
Show Gist options
  • Save mwrites/831d59829e463208e063498b447fb499 to your computer and use it in GitHub Desktop.
Save mwrites/831d59829e463208e063498b447fb499 to your computer and use it in GitHub Desktop.
# UIPresentation Controlers
https://realm.io/news/slug-jesse-squires-swifty-view-controller-presenters/
Transition > transiting state
Presentation > final state
Presentation hook into the transition API
responsibilities
- positioning
- managing the chrome
- adaptation
Not coupled with transition objects
3 phases
1. Presentation (moving onscreen)
2. Management (size class changes, size change, device rotation)
3. Dismissal (moving offscreen)
+ Transitioning
modalPresentationStyle > actually vending a presentation controller for the style
- Alerts: _UIAlertControllerAlertPResentationController
- ActionSheet (iphone): _UIAlertControllerActionSheetCompactPC
- ActionSheet(ipad): _UIAlertControllerActionSheetRegularPC
## Presenting
- presentVC
- pushVC
- showVC (adaptive, mostly used for container VC, e.g: SplitVC)
- showDetailVC (adaptive, mostly used for container VC, e.g: SplitVC)
## Special Presentation
- UIAlertController
- UISearchController
- UIPopoverPresentationController > the only custom presentation ctrl publicly available in UIKit
## Custom Presentation Controller
### 1. Subclass UIPresentationController
1. Transitioning and Chrome
* presentationTransitionWillBegin()
* dismissalTransitionWillBegin()
2. Positioning
* sizeForChildContentContainer(child, withParentContainerSize:) -> CGSize
* frameOfPresentedViewInContainerView()
3. Adaptivity
* adaptivePresentationStyle() -> UIModalPresentationStyle > weird that we cannot provide our own presentation style
* shouldPresentInFullscreen() -> Bool
* containerViewWillLayoutSubviews() -> used for fine grained control
### 2. Vend Controller
1. UIViewControllerTransitioningDelegate
* presentingVC conforms to delegate
* set delegate on presented VC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment