Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inloop/uiviewcontroller-displaychild
UIViewController containment made easy
https://github.com/inloop/uiviewcontroller-displaychild
display-child embeding ios swift
Last synced: 6 days ago
JSON representation
UIViewController containment made easy
- Host: GitHub
- URL: https://github.com/inloop/uiviewcontroller-displaychild
- Owner: inloop
- License: mit
- Created: 2018-04-19T13:39:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-23T10:46:58.000Z (about 4 years ago)
- Last Synced: 2024-10-28T11:51:11.410Z (16 days ago)
- Topics: display-child, embeding, ios, swift
- Language: Swift
- Homepage:
- Size: 44.9 KB
- Stars: 4
- Watchers: 17
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# UIViewController-DisplayChild
[![CI Status](https://img.shields.io/travis/inloop/UIViewController-DisplayChild.svg?style=flat)](https://travis-ci.org/inloop/UIViewController-DisplayChild)
[![License](https://img.shields.io/cocoapods/l/UIViewController-DisplayChild.svg?style=flat)](https://cocoapods.org/pods/UIViewController-DisplayChild)
[![Version](https://img.shields.io/cocoapods/v/UIViewController-DisplayChild.svg?style=flat)](https://cocoapods.org/pods/UIViewController-DisplayChild)
[![Platform](https://img.shields.io/cocoapods/p/UIViewController-DisplayChild.svg?style=flat)](https://cocoapods.org/pods/UIViewController-DisplayChild)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)**The problem:** sometimes you need to embed a controller, but it might be embedded already. E.g. you have an empty view, and you do refresh only to get empty view again. If you do not check for its existence, you might end up creating a new instance unneccessarily. This can also have bad side effects when there is some heavier work in viewDidLoad for example.
**The solution:** transition to type, instead of an instance. If the instance does not exist, it is created for you and you have a possibility to configure it after initialization via `configuration` closure. If the instance does exist, only the configuration closure is performed so that you can display a new content. You do not have to worry anymore whether the controller you intent to embed is already presented.
Example:
```swift
import UIViewController_DisplayChilddisplayChild(
ofType: ErrorViewController.self,
in: containerView,
animated: false,
configuration: { controller in
controller.model = model
}
)
```