Swift programmatically set segues

泪湿孤枕 提交于 2019-11-30 04:56:52

问题


I have a piece of parse code that checks to see if a user is logged in:

PFUser.logInWithUsernameInBackground("myname", password:"mypass") {
  (user: PFUser!, error: NSError!) -> Void in
  if user != nil {
    // Do stuff after successful login.
  } else {
    // The login failed. Check error to see why.
  }
}

After the successful login I want to send the user to a new segue. I can't do this in the storyboard because I only want the segue to occur if the conditions are met. Is there anyway to create a segue programmatically?


回答1:


You can use:

performSegueWithIdentifier("yourSegueIdentifier", sender: nil)

You dont need to "create" a segue programmatically, just connect your ViewControllers and create a Segue. With performSegueWithIdentifier you can call your segue manually if needed.



来源:https://stackoverflow.com/questions/26536080/swift-programmatically-set-segues

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