NavigationController无法导航到destlated ViewController

时间:2017-10-02 05:57:46

标签: swift3

这是我的导航流程:

VC1 - > VC2 - > V3

在VC1(登陆页面或主页面):

我使用segue通过点击按钮导航到VC2

VC2的问题:
VC2中的NavigationController无法正常工作,它不会导航到指定的目标UIViewControllers。

在VC2中,在满足某些条件后,我需要在代码中使用navigationalController导航到VC3。

这里是VC2的代码:

 override func viewDidAppear() {

  let defaults = UserDefaults.standard

  if defaults.object(forKey: "SessionToken") == nil {

  let VC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentitfier: "VC3") as! VC3


  self.dismiss(animated: true, completion: nil)

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


    } else {

                   //-- code for other task--

      }

 }



Override func viewDidLoad() {

  super.viewDidLoad()


 here: I have code to setup calendar functions and others


}

更新:

document.getElementById("BigImage");

请帮忙。

由于

1 个答案:

答案 0 :(得分:1)

试试这个:

override func viewDidAppear(_ animated: Bool) {

    super.viewDidAppear(animated)

    let defaults = UserDefaults.standard

    if defaults.object(forKey: "SessionToken") == nil {


        let VC = self.storyboard?.instantiateViewController(withIdentifier: "VC3") as! VC3

        self.present(VC, animated: true) {

        }


    } else {

        //-- code for other task--

    }
}