My goal is to show a View Controller programmatically
Current View Controller
and then, if some event gets called or something, (API, or Websocket) I want to call these Views programmatically
But I want to call the last view Controller first and it is supposed to be on top of the first View controller
So technically the last View will have
Transition is Cross Dissolve
Presentation is Over Current Context
How would I do this?
I think the best way for a reusable view is to create a xib file. Then you can create a singleton and call this view every time you want to show this modal view.
To ensure that your view does not overlap with anything, you must add it not to the current controller, but to AppDelegate window.
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window!.addSubview(yourModalView)
As per your requirement, you can set a storyBoardID for your navigation controller.
On a particular event just instantiate the Navigation controller
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let myNavController = storyboard.instantiateViewController(withIdentifier: "MyStoryboardId") as? UINavigationController
then present or show this navigation controller
self.present(myNavController, animated: true, completion: nil)
On viewDidLoad()
method of first view controller perform the segue to popupViewController.
Now the secondView will show above the first view controller. you can dismiss this view after using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With