What is the best method to transition between view controllers2019 Community Moderator ElectionPassing Data between View ControllersWhy don't use var at the beginning?How to use Storyboard view controllers without reloading each time they showDeallocate UIViewController after SegueSwift Transferred Data between View Controllers stays emptyCreate a segue to another view controller through search bar?Swift: restore previous view controller after an unwind segueSwift Error - Use of undeclared type 'cell' - Collection ViewHow to segue programmatically from 1VC to 2VC (Swift)Selection segue (unwind) on tableView cells not working after search results displaying on it

Help! My Character is too much for her story!

ESPP--any reason not to go all in?

How does a sound wave propagate?

Unfamiliar notation in Diabelli's "Duet in D" for piano

How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?

How does learning spells work when leveling a multiclass character?

Was this cameo in Captain Marvel computer generated?

Is the differential, dp, exact or not?

Why would /etc/passwd be used every time someone executes `ls -l` command?

Why is there an extra space when I type "ls" on the Desktop?

Can I negotiate a patent idea for a raise, under French law?

PTIJ: Sport in the Torah

Precision notation for voltmeters

What can I do if someone tampers with my SSH public key?

Is it a Cyclops number? "Nobody" knows!

Boss Telling direct supervisor I snitched

Giving a career talk in my old university, how prominently should I tell students my salary?

Short SF story. Females use stingers to implant eggs in yearfathers

Is there a logarithm base for which the logarithm becomes an identity function?

How to educate team mate to take screenshots for bugs with out unwanted stuff

An Undercover Army

What does *dead* mean in *What do you mean, dead?*?

Limpar string com Regex

The (Easy) Road to Code



What is the best method to transition between view controllers



2019 Community Moderator ElectionPassing Data between View ControllersWhy don't use var at the beginning?How to use Storyboard view controllers without reloading each time they showDeallocate UIViewController after SegueSwift Transferred Data between View Controllers stays emptyCreate a segue to another view controller through search bar?Swift: restore previous view controller after an unwind segueSwift Error - Use of undeclared type 'cell' - Collection ViewHow to segue programmatically from 1VC to 2VC (Swift)Selection segue (unwind) on tableView cells not working after search results displaying on it










-1















In experimenting with view controllers in Swift 4, various searches show there are several different methods to move between view controllers. I first starting using this code to open a new view controller:



let vc = self.storyboard?.instantiateViewController(withIdentifier: "registration2") as! ViewRegistration2
self.present(vc, animated: true, completion: nil)


but then I found this method:



performSeque(withIdentifier: "sequeName", sender: self)


With this method I had to create a segue and name it, which is fine, but I wanted to know which is best practice and/or is there a reason to use one method or the other?










share|improve this question
























  • Unrelated you can simplify your first example to let vc = storyboard!.instantiateViewController(withIdentifier: "registration2") and present(vc, animated: true).

    – Rob
    2 days ago











  • One might prefer the latter so that the storyboard graphically represents the all the relationships between the scenes in your app. We might manually present where we have to (e.g. the view controller was instantiated via NIB). We might manually instantiateViewController when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).

    – Rob
    2 days ago
















-1















In experimenting with view controllers in Swift 4, various searches show there are several different methods to move between view controllers. I first starting using this code to open a new view controller:



let vc = self.storyboard?.instantiateViewController(withIdentifier: "registration2") as! ViewRegistration2
self.present(vc, animated: true, completion: nil)


but then I found this method:



performSeque(withIdentifier: "sequeName", sender: self)


With this method I had to create a segue and name it, which is fine, but I wanted to know which is best practice and/or is there a reason to use one method or the other?










share|improve this question
























  • Unrelated you can simplify your first example to let vc = storyboard!.instantiateViewController(withIdentifier: "registration2") and present(vc, animated: true).

    – Rob
    2 days ago











  • One might prefer the latter so that the storyboard graphically represents the all the relationships between the scenes in your app. We might manually present where we have to (e.g. the view controller was instantiated via NIB). We might manually instantiateViewController when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).

    – Rob
    2 days ago














-1












-1








-1








In experimenting with view controllers in Swift 4, various searches show there are several different methods to move between view controllers. I first starting using this code to open a new view controller:



let vc = self.storyboard?.instantiateViewController(withIdentifier: "registration2") as! ViewRegistration2
self.present(vc, animated: true, completion: nil)


but then I found this method:



performSeque(withIdentifier: "sequeName", sender: self)


With this method I had to create a segue and name it, which is fine, but I wanted to know which is best practice and/or is there a reason to use one method or the other?










share|improve this question
















In experimenting with view controllers in Swift 4, various searches show there are several different methods to move between view controllers. I first starting using this code to open a new view controller:



let vc = self.storyboard?.instantiateViewController(withIdentifier: "registration2") as! ViewRegistration2
self.present(vc, animated: true, completion: nil)


but then I found this method:



performSeque(withIdentifier: "sequeName", sender: self)


With this method I had to create a segue and name it, which is fine, but I wanted to know which is best practice and/or is there a reason to use one method or the other?







ios swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Rob

303k49565735




303k49565735










asked 2 days ago









ChrisChris

115110




115110












  • Unrelated you can simplify your first example to let vc = storyboard!.instantiateViewController(withIdentifier: "registration2") and present(vc, animated: true).

    – Rob
    2 days ago











  • One might prefer the latter so that the storyboard graphically represents the all the relationships between the scenes in your app. We might manually present where we have to (e.g. the view controller was instantiated via NIB). We might manually instantiateViewController when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).

    – Rob
    2 days ago


















  • Unrelated you can simplify your first example to let vc = storyboard!.instantiateViewController(withIdentifier: "registration2") and present(vc, animated: true).

    – Rob
    2 days ago











  • One might prefer the latter so that the storyboard graphically represents the all the relationships between the scenes in your app. We might manually present where we have to (e.g. the view controller was instantiated via NIB). We might manually instantiateViewController when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).

    – Rob
    2 days ago

















Unrelated you can simplify your first example to let vc = storyboard!.instantiateViewController(withIdentifier: "registration2") and present(vc, animated: true).

– Rob
2 days ago





Unrelated you can simplify your first example to let vc = storyboard!.instantiateViewController(withIdentifier: "registration2") and present(vc, animated: true).

– Rob
2 days ago













One might prefer the latter so that the storyboard graphically represents the all the relationships between the scenes in your app. We might manually present where we have to (e.g. the view controller was instantiated via NIB). We might manually instantiateViewController when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).

– Rob
2 days ago






One might prefer the latter so that the storyboard graphically represents the all the relationships between the scenes in your app. We might manually present where we have to (e.g. the view controller was instantiated via NIB). We might manually instantiateViewController when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).

– Rob
2 days ago













2 Answers
2






active

oldest

votes


















2














Segues can only be used with storyboards. They are normally instantiated automatically, and created in the storyboard. You can also perform segues in code.
When using segues, the storyboard instantiates the view controller and triggers the transition.



When you aren't using storyboards, you present view controllers with UIViewController.present(:animated:completion:).



It looks like you are using storyboards, and in that case you should use segues, because the first code snippet is essentially doing what segues do.






share|improve this answer






























    0














    You can present ViewControllers using present function on code.
    Like this.
    self.present(VC, animated: true, completion: nil)



    If there are ViewControllers on Storyboard, performSeque is a good way.






    share|improve this answer








    New contributor




    Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.



















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027569%2fwhat-is-the-best-method-to-transition-between-view-controllers%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      Segues can only be used with storyboards. They are normally instantiated automatically, and created in the storyboard. You can also perform segues in code.
      When using segues, the storyboard instantiates the view controller and triggers the transition.



      When you aren't using storyboards, you present view controllers with UIViewController.present(:animated:completion:).



      It looks like you are using storyboards, and in that case you should use segues, because the first code snippet is essentially doing what segues do.






      share|improve this answer



























        2














        Segues can only be used with storyboards. They are normally instantiated automatically, and created in the storyboard. You can also perform segues in code.
        When using segues, the storyboard instantiates the view controller and triggers the transition.



        When you aren't using storyboards, you present view controllers with UIViewController.present(:animated:completion:).



        It looks like you are using storyboards, and in that case you should use segues, because the first code snippet is essentially doing what segues do.






        share|improve this answer

























          2












          2








          2







          Segues can only be used with storyboards. They are normally instantiated automatically, and created in the storyboard. You can also perform segues in code.
          When using segues, the storyboard instantiates the view controller and triggers the transition.



          When you aren't using storyboards, you present view controllers with UIViewController.present(:animated:completion:).



          It looks like you are using storyboards, and in that case you should use segues, because the first code snippet is essentially doing what segues do.






          share|improve this answer













          Segues can only be used with storyboards. They are normally instantiated automatically, and created in the storyboard. You can also perform segues in code.
          When using segues, the storyboard instantiates the view controller and triggers the transition.



          When you aren't using storyboards, you present view controllers with UIViewController.present(:animated:completion:).



          It looks like you are using storyboards, and in that case you should use segues, because the first code snippet is essentially doing what segues do.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Chandler De AngelisChandler De Angelis

          1,44352343




          1,44352343























              0














              You can present ViewControllers using present function on code.
              Like this.
              self.present(VC, animated: true, completion: nil)



              If there are ViewControllers on Storyboard, performSeque is a good way.






              share|improve this answer








              New contributor




              Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                You can present ViewControllers using present function on code.
                Like this.
                self.present(VC, animated: true, completion: nil)



                If there are ViewControllers on Storyboard, performSeque is a good way.






                share|improve this answer








                New contributor




                Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  You can present ViewControllers using present function on code.
                  Like this.
                  self.present(VC, animated: true, completion: nil)



                  If there are ViewControllers on Storyboard, performSeque is a good way.






                  share|improve this answer








                  New contributor




                  Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  You can present ViewControllers using present function on code.
                  Like this.
                  self.present(VC, animated: true, completion: nil)



                  If there are ViewControllers on Storyboard, performSeque is a good way.







                  share|improve this answer








                  New contributor




                  Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 2 days ago









                  Pavel L.Pavel L.

                  11




                  11




                  New contributor




                  Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Pavel L. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027569%2fwhat-is-the-best-method-to-transition-between-view-controllers%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme