My intent was to create a master scene and view controller that was in control most of the time, but when logic demanded it would segue to one of several other scenes. Each of these "other" scenes would return to the master view controller using rewind segues. Which other scene was chosen was determined by logic in the master view controller. This worked fine until I found a need to transition from one of the "other" scenes to a different "other" scene without presenting anything from the master scene. I want to put a performSegueWithIdentifier in the master view controller before anything is presented.
I have tried putting the performSegue.. in the method that catches the rewind segue, in the viewWillAppear method, in a block kicked off async from the rewind method, but in all cases I see the performSegueWithIdenitifer method execute, then the appropriate prepareForSegue but then control returns to the master view controller and the scene I get in the device is from the master view controller.
I tried to look at other methods and it would seem that building a custom container view controller is one way of doing this, but it does not seem right since all the "other" scenes I want to segue to are push segues and take over the entire screen.
Is there some reason that a view controller that has received control from a rewind segue cannot then kickoff a segue without ever appearing itself? Is the Custom container view controller the correct way to do this? And if the latter, do I let the storyboard set up the embed segues to all the other view controllers, or do I leave them unconnected in the storyboard and load them in code?
Thanks in advance, ##warning - novice here - this is my first real project##
Related
I have two view controllers, one that shows some content in a list and one that renders a map. I give users the option to switch between the two by tapping a button. I'm currently using a segue for the button to switch between the two views, but because of the nature of segues I end up re-initializing the view controller each time, generating unnecessary network traffic.
I'm looking for a way to transition between these two views in such a way that the controllers are only initialized once, the first time they're invoked. Subsequent invocations of these controllers would just use whatever instance was already loaded in memory.
Is this achievable? If so, what do I use? pushViewController also ends up calling viewDidLoad on the controller being pushed onto the stack
I have an interactive custom view controller transition based on a storyboard segue (push).
The target view controller takes some time to be loaded as it contains a table with a lot of data; moreover when I leave this vc and come back, I need the table to maintain its content offset and not to start each time from the first row.
In order to achieve these two points I need the target vc to be a kind of singleton, and not to be deallocated/reallocated every time.
Any suggestion?
Thanks,
DAN
Don't use a segue -- they always instantiate new view controllers. Create a property for the destination view controller in the controller that initiates the transition, and only instantiate it the first time you go to it. Push the new controller in code.
What I need to do is basically build a container(view controller) that can change its child view controller dynamically and also set it's initial view controller dynamically.
I never used the Embed segue before so I thought I'll give it a shot.
However, using it seems to allow me to change the child view controller dynamically using a custom segue between the children view controllers but the initial view controllers seem to be fixed to the one I dragged the segue to in the StoryBoard(The custom segue here would be something alone these lines).
I know I can achieve what i'm looking for by creating x custom segue (where x is the number of children VCs I need) from the container view controller directly to the children and just calling these segues in code based on my needs.
But if that's the only way, what's the reason for using the "Embed" segue, is it only for really simple scenario's ?
An embed segue is not just for really simple scenarii. It can get pretty complicated. A major purpose is to cleanly separate code related to different concerns, that may still coexist on the same screen, into different view controllers. For instance, you could have an authentication controller and a preferences controller, both embedded into a single profile controller.
This is probably a very simple question but I can't find the answer to it.
I am working on a new project that uses Storyboards for the first time.
I have a number of view controllers that connect the way I want them to.
Each view controller has an info button.
I have one view controller (AboutViewController) that I want to use to display the info for all the view controllers. I am currently calling this via a popover segue from each screen. So I have one destination view controller (AVC) that I am calling from a number of VCs- VC1toAVC, VC2toAVC, VC3toAVC etc. I want two textfields in AVC to change, depending on which VC called it.
So here's the problem- how can I tell which view controller called the popup? It's basically the view that's below the popover. Currently I'm storing it as a variable but that's not ideal. I'm guessing it has something to do with the segue identifiers?
Any and all help much appreciated!
One approach to this is adding a property to your pop up view controller and then define the
prepareForSegue:sender:
method so you set your destination view controller's property to the sender of the segue.
I'm developing an application that works with 2 different views. Today I noticed that every time I step from view 1 to view 2 the app creates a new view.
And when I return to the previous view it simply creates a new instance of view1, ie it creates a new view in memory. (and keep the previous)
I would like to use the same view without creating a new instance (a new view in memory) each time the user passes a view to another.
I would like transit between just the 2 views that I created.
Note: I'm using the iOS 6 with Storyboard and ARC. And the transition is made by a tap gesture recognizer. Once I tap the view it goes to the next view using a modal transition.
When you go from view controller 1 to view controller 2 as a modal (presented) view controller, you use a modal segue. This will indeed create a new instance of view controller 2. When you go back, in iOS 6, you must use an unwind segue to the first view controller. This will cause the view controller 2 to go out of existence, and it will use the existing view controller 1, not create a new view controller 1.
Here's my explanation of unwind segues.
http://www.apeth.com/iOSBook/ch19.html#_unwind_segues
(Either that, or don't use a segue at all; just call dismissViewController yourself, as we did in iOS 5 before unwind segues existed. Or don't use a storyboard in the first place; they really aren't necessary. Here's my explanation of presented ["modal"] view controllers: http://www.apeth.com/iOSBook/ch19.html#_presented_view_controller)