问题
I have a view controller named HomeVC which acts as a center page to navigate to targeted view controllers based on conditions.
HomeVC is the Landing Page or main page.
In HomeVC, I have some UIControls like calendars and others.
Problem: The HomeVC shows up a brief second before navigating to VC2 when the condition is met.
Requirements:
How not to show HomeVC when condition is met when navigating to another UIViewController?
Update: Requirements - not showing the UiControls on HomeVC
Here is the code for HomeVC:
override func viewDidAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let defaults = UserDefaults.standard
if defaults.object(forKey: "SessionToken") == nil {
let VC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentitfier: "VC2") as! VC2
self.dismiss(animated: true, completion: nil)
self.navigationController?.present(VC, animated: true)
} else {
//-- code for other task--
}
}
Your help is appreciated. Thanks
回答1:
Just turn off the dismissing and presenting animation to achieve that.
self.navigationController?.present(VC, animated: false)
self.dismiss(animated: false)
来源:https://stackoverflow.com/questions/46521957/which-event-should-i-use-in-landing-page-home-so-that-it-wont-show-up-when-na