Note that there are some explanatory texts on larger screens.

plurals
  1. POThree20's URL-based navigation + tab bar example?
    text
    copied!<p>I just found out how easy it is (or at least is supposed to be) to do <a href="http://three20.info/ui/navigation" rel="nofollow noreferrer">state persistence with Three20 library</a>. However, I am unable to figure out how to use the URL mapper with a tab bar (<code>UITabBarController</code>).</p> <p>The situation is this:</p> <ol> <li>I have four tabs and different controllers for them: <code>FirstViewController</code>, <code>SecondViewController</code>, <code>ThirdViewController</code> and <code>FourthViewController</code>.</li> <li>I want to map those to <code>tt://tabs/first</code>, ..., <code>tt://tabs/fourth</code> respectively, and have them saved somewhere when application closes so that the previously viewed tab is automatically opened when the application starts again.</li> </ol> <p>My code so far:</p> <pre><code>// Init the tab bar tabBarController = [[UITabBarController alloc] init]; [tabBarController setDelegate:self]; // Init the navigator TTNavigator *navigator = [TTNavigator navigator]; [navigator setWindow:window]; [navigator setPersistenceMode:TTNavigatorPersistenceModeAll]; // Begin mapping TTURLMap *map = [navigator URLMap]; [map from:@"tt://tabs" toViewController:[UIViewController class]]; [map from:@"tt://tabs/first" toViewController:[FirstViewController class]]; [map from:@"tt://tabs/second" toViewController:[SecondViewController class]]; [map from:@"tt://tabs/third" toViewController:[ThirdViewController class]]; [map from:@"tt://tabs/fourth" toViewController:[FourthViewController class]]; // Try restoring if (! [navigator restoreViewControllers]) { // Open default TTURLAction *defaultAction = [[TTURLAction alloc] initWithURLPath:@"tt://tabs/default"]; [defaultAction setParentURLPath:@"tt://tabs"]; [navigator openURLAction:defaultAction]; } // Put view controllers to tab bar [tabBarController setViewControllers:[NSArray arrayWithObjects: [[FirstViewController alloc] init], [[SecondViewController alloc] init], [[ThirdViewController alloc] init], [[FourthViewController alloc] init], nil]]; [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; </code></pre> <p>How do I get <code>TTNavigator</code> to open the last opened tab, and if there's none - fallback to <code>FirstViewController</code>?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload