Which event should I use in Landing Page (Home) so that it won't show up when navigating to other VC?

北城余情 提交于 2019-12-13 03:58:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!