Skip to content

Instantly share code, notes, and snippets.

@ufo22940268
Created July 2, 2019 02:07
Show Gist options
  • Save ufo22940268/2949fdf59c9860292f263ebb1e8036d7 to your computer and use it in GitHub Desktop.
Save ufo22940268/2949fdf59c9860292f263ebb1e8036d7 to your computer and use it in GitHub Desktop.
Dismiss multi view controllers
//: Playground - noun: a place where people can play
import UIKit
import AVKit
import PlaygroundSupport
class NCB: UINavigationController {
override func viewDidLoad() {
}
}
class VCC: UIViewController {
override func viewDidLoad() {
view.backgroundColor = .orange
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.navigationController?.dismiss(animated: true, completion: nil)
}
}
}
class VCB: UIViewController {
override func viewDidLoad() {
let vcc = VCC()
view.backgroundColor = .green
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.navigationController?.pushViewController(vcc, animated: true)
}
}
}
class VCA: UIViewController {
override func viewDidLoad() {
view.backgroundColor = .yellow
let vcb = VCB()
let ncb = NCB(rootViewController: vcb)
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.present(ncb, animated: true, completion: nil)
}
}
}
let vca = VCA()
PlaygroundPage.current.liveView = vca
PlaygroundPage.current.needsIndefiniteExecution = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment