本文介绍了我应该在登陆页面(主页)中使用哪个事件,以便它在导航到其他 VC 时不会出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 HomeVC 的视图控制器,它充当中心页面,根据条件导航到目标视图控制器.

I have a view controller named HomeVC which acts as a center page to navigate to targeted view controllers based on conditions.

HomeVC 是登陆页面或主页.

HomeVC 中,我有一些 UIControl 像日历等.

In HomeVC, I have some UIControls like calendars and others.

问题:当条件满足时,HomeVC 在导航到 VC2 之前会出现一秒钟.

Problem: The HomeVC shows up a brief second before navigating to VC2 when the condition is met.

要求:

导航到另一个UIViewController时,如何在满足条件时不显示HomeVC?

How not to show HomeVC when condition is met when navigating to another UIViewController?

更新:要求- 未在 HomeVC 上显示 UiControls

Update: Requirements- not showing the UiControls on HomeVC

这是 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--

 }

}

感谢您的帮助.谢谢

推荐答案

只需关闭关闭和呈现动画即可.

Just turn off the dismissing and presenting animation to achieve that.

self.navigationController?.present(VC, animated: false)

self.dismiss(animated: false)

这篇关于我应该在登陆页面(主页)中使用哪个事件,以便它在导航到其他 VC 时不会出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:57