ios - Segue in swift based on a logic -


i want show 1 of 2 views in swift based on if statement when application first launches how do logic

if signupconfirmed == true { // have show 1 view  } else { // have show view  } 

one way can initiate viewcontroller identifier below code:

var signupconfirmed = true @ibaction func signuppressed(sender: anyobject) {      if signupconfirmed {         // have show 1 view         let storyboard = uistoryboard(name: "main", bundle: nil)         let vc = storyboard.instantiateviewcontrollerwithidentifier("first") as! sviewcontroller         self.presentviewcontroller(vc, animated: true, completion: nil)     } else {         // have show view         let storyboard = uistoryboard(name: "main", bundle: nil)         let vc = storyboard.instantiateviewcontrollerwithidentifier("second") as! tviewcontroller         self.presentviewcontroller(vc, animated: true, completion: nil)     } } 

update:

you can perform action in appdelegate.swift

here code:

func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool {      let signupconfirmed = nsuserdefaults.standarduserdefaults().boolforkey("signup")     self.window = uiwindow(frame: uiscreen.mainscreen().bounds)     var initialviewcontroller = uiviewcontroller()     var storyboard = uistoryboard(name: "main", bundle: nil)     if signupconfirmed {         initialviewcontroller = storyboard.instantiateviewcontrollerwithidentifier("first") as! uiviewcontroller     } else{         initialviewcontroller = storyboard.instantiateviewcontrollerwithidentifier("second") as! uiviewcontroller     }      self.window?.rootviewcontroller = initialviewcontroller     self.window?.makekeyandvisible()     return true } 

hope you.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -