简体   繁体   中英

Navigation Controllers/View Controllers working with a stack

I am trying to create an iPhone game app with the Swift programming language using Xcode. I created the project as a single-view application, and I have been adding view controllers and connecting them up with segues as I need them, using the Storyboard.

From what I have come to understand after hours of working on this (better late than never), is that VCs do not use a stack, while a navigation controller connected to other VCs does use a stack. So, assuming there is no navigation controller being used, if I use a "show" segue from one VC to another, it won't push the proceeding VC onto the VC that initiated the segue. It will instead show it "modally".

I have a few questions regarding this.

  1. What is occurring when I am moving between the VCs, if they are not using a stack? For instance, when I move from one VC to another, is the previous VC removed from memory, or does the memory keep taking on more and more copies of VCs as I move between them?

  2. Since VCs cannot pop from a stack without initially having a navigation controller, is there any way to keep my app from crashing, such as a particular way to segue between VCs?

  3. When a project is created in single-view application/tabbed application, etc., does this affect what the app will be capable of doing indefinitely, or does Xcode just create a basic template to start from? For instance, could I start off with a single-view application, but turn it into a tabbed-application? I assume the answer is yes, but confirmation is always nice.

Any information regarding these questions is greatly appreciated! Thanks!

What is occurring when I am moving between the VCs, if they are not using a stack? For instance, when I move from one VC to another, is the previous VC removed from memory, or does the memory keep taking on more and more copies of VCs as I move between them?

The previous VC stays in memory. Each new segue creates a new VC.

Since VCs cannot pop from a stack without initially having a navigation controller, is there any way to keep my app from crashing, such as a particular way to segue between VCs?

There is only one segue type that does not create a new VC and that is the unwind segue. You use it to return to the previous VC. Search Stack Overflow for "unwind segue" to see how to set that up.

When a project is created in single-view application/tabbed application, etc., does this affect what the app will be capable of doing indefinitely, or does Xcode just create a basic template to start from? For instance, could I start off with a single-view application, but turn it into a tabbed-application? I assume the answer is yes, but confirmation is always nice.

The templates just start you off with the appropriate Storyboard and ViewControllers for that template type. You can easily delete or modify them to change what your application does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM