views:

37

answers:

1

In the iPhone application I'm developing, I have a need to return the user to the previous screen they were using when, for instance, the application was interrupted by, say, a phone call.

The application is driven by a navigation controller, and the user may be several layers deep into the application. As such, I think that I need to traverse the navigation controller logic to bring the user to the point that they were previously at, with all return navigation logic n place.

I'm comfortable that I can force the application to navigate down to the required level through code, but I would like to hide the screen switching and animations that would occur while this is going on, thus presenting the user with (apparently) a direct path to their last used screen, rather than showing them the underlying navigation that's occurred.

Could somebody please point me to some method of suppressing the intermediate displays?

Does anyone have other methods to perform this sort of task?

Thanks in advance for all suggestions.

+1  A: 

I suggest you take a look at the Three20 project which contains a feature called "URL-based navigation", which might help you, since you only should to store the URL of the current visible view controller, and restore it when the app resumes after the phone call:

TTNavigationCenter is for those grizzled old web developers like myself who want to organize their app by "pages" which can be displayed by visiting a URL.

Your view controllers can simply register URL patterns that they handle, and when those URLs are visited the controllers will be created and displayed. You can also register generic actions that are called when a URL is visited.

TTNavigationCenter also persists and restores the full path of navigation controllers and modal view controllers, so your users can quite the app and come back exactly where they left off.

(source: Three20 Github project)

Adrian Kosmaczewski
Thank you.I shall look at that code, but I'm unsure of the relevance of "URL based navigation" to my problem, as this is not a web based app. URLs are not involved.I'm going from screen1 -> screen2 -> screen3 -> screen4 and none of those screens will contain any web based data. They will each load their own data payload, and if a call is received while a user is on screen4, then I need to save the state of that window (already solved) and then, when the app is next launched, restore the app back to screen4, with the same data payload.
Redback
the relation of three20's url nav to your problem is not obvious, but Adrian is correct. Imagine an web MVC pattern where URL routes match controllers. WIth Three20, an URL mapping can choose how a controller is instantiated. Factory Or Shared. A Shared controller will only be built once. If you GoTo a shared controller url, three20 will actually switch to whereever that shared controller is loaded. if it's already the first in the UINav stack, it *should* go back to that with a nice animation, without unrolling the whole Uinav stack
CVertex
I should add that Three20's url engine attempts to bring web MVC to iphone mvc... and it does so extremely well. I'd be fux0red if i didn't have it
CVertex
Ok, thanks for the further clarification. That looks to be very interesting, and should make for a fun night of learning. :)
Redback