0

i'm trying to create an application using three20 but i'm having issue to set the root viewcontroller for the TTnavigator.

this is the mapping code

    TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://root/(loadFromNib:)/(withClass:)" toViewController:[MainViewController class]];

clearly i'm doing something wrong

thanks in advance :)

Janub
  • 1,594
  • 14
  • 26
  • 1
    you're using TTNavigator. that's what you're doing wrong ;-) you can still use three20 without TTNavigator. just push / pop your TTViewControllers in the old "apple fashion" – aporat Apr 17 '12 at 23:01

1 Answers1

1

I Figure it out finally

this is my solution

    -(void)applicationDidFinishLaunching:(UIApplication *)application
{
    TTNavigator * navigator = [TTNavigator navigator];
    navigator.persistenceMode = TTNavigatorPersistenceModeAll;
    navigator.window = self.window;

    TTURLMap* map = navigator.URLMap;
    [map from:@"*" toViewController:[TTWebController class]];
    [map from:@"tt://root/(loadFromNib:)/(withClass:)" toSharedViewController:self];

    if (![navigator restoreViewControllers]) {
        [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://root/MainViewController/MainViewController"]];
    }

}
/**
 * Loads the given viewcontroller from the nib
 */
- (UIViewController*)loadFromNib:(NSString *)nibName withClass:className {
    UIViewController* newController = [[NSClassFromString(className) alloc]
                                       initWithNibName:nibName bundle:nil];
    [newController autorelease];

    return newController;
}


///////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * Loads the given viewcontroller from the the nib with the same name as the
 * class
 */
- (UIViewController*)loadFromNib:(NSString*)className {
    return [self loadFromNib:className withClass:className];
}


///////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * Loads the given viewcontroller by name
 */
- (UIViewController *)loadFromVC:(NSString *)className {
    UIViewController * newController = [[ NSClassFromString(className) alloc] init];
    [newController autorelease];

    return newController;
}


- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)URL {
    [[TTNavigator navigator] openURLAction:[TTURLAction actionWithURLPath:URL.absoluteString]];
    return YES;
}
Janub
  • 1,594
  • 14
  • 26