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
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
add a comment |
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
Unrelated you can simplify your first example tolet vc = storyboard!.instantiateViewController(withIdentifier: "registration2")
andpresent(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 manuallypresent
where we have to (e.g. the view controller was instantiated via NIB). We might manuallyinstantiateViewController
when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).
– Rob
2 days ago
add a comment |
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
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
ios swift
edited 2 days ago
Rob
303k49565735
303k49565735
asked 2 days ago
ChrisChris
115110
115110
Unrelated you can simplify your first example tolet vc = storyboard!.instantiateViewController(withIdentifier: "registration2")
andpresent(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 manuallypresent
where we have to (e.g. the view controller was instantiated via NIB). We might manuallyinstantiateViewController
when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).
– Rob
2 days ago
add a comment |
Unrelated you can simplify your first example tolet vc = storyboard!.instantiateViewController(withIdentifier: "registration2")
andpresent(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 manuallypresent
where we have to (e.g. the view controller was instantiated via NIB). We might manuallyinstantiateViewController
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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.
New contributor
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered 2 days ago
Chandler De AngelisChandler De Angelis
1,44352343
1,44352343
add a comment |
add a comment |
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.
New contributor
add a comment |
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.
New contributor
add a comment |
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.
New contributor
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.
New contributor
New contributor
answered 2 days ago
Pavel L.Pavel L.
11
11
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Unrelated you can simplify your first example to
let vc = storyboard!.instantiateViewController(withIdentifier: "registration2")
andpresent(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 manuallyinstantiateViewController
when we’re doing something manual with the view controller later (e.g. view controller containment, etc.).– Rob
2 days ago