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

                      Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                      Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                      How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page