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)
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.
将当前方法的“动画”参数设置为false
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.