Reputation: 17
I have implemented two different UIViewControllers
, that should replace each other based on server respond and user actions. For simplicity let's think that we have two UIViewControllers
with button
replace with another, that should trigger this replacement.
Now I need to do that replace part, but the problem is there is some delay between dismissing one screen and showing the other. I want to somehow get rid of it. I show UIViewController
modally with present method
.
I thought about making these two screen as views in xib-files, and one UIViewController
that will be loading these xibs, adding them as subViews
and replacing one subView
with another when it needs it, but maybe there is a way to do that with two UIViewControllers
?
Code that I use to present controller:
let vc = UIViewController1()
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: false, completion: nil)
And to dismiss:
self.dismiss(animated: false, completion: nil)
Upvotes: 0
Views: 728
Reputation: 535
you can add a container view and in that view you can simply add your desired controller as the child view controller official doc reference.
Upvotes: 1
Reputation: 1679
let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "YourViewController") as! YourViewController
self.present(vc, animated: false, completion: nil)
self.dismiss(animated: false, completion: nil)
First you send notification to parent class for present another 'viewController' and then dismiss current class
Upvotes: 0