开发者

How to launch a TTTableView based view with TTLauncherView?

I'm very newbie with Three20. I'm trying to make an TTLauncherView based interface, without success for now.

My LauncherView contains a button, mapped to an URL. When I click on this button, I want a TTTableView based to be displayed on screen. But I have nothing.

Here is a piece of my AppDelegate code :

[map from:@"tt://rank" toViewController:[RankController class]];

And the LauncherView code (a piece, too) :

launcherView.pages = [NSArray arrayWithObjects:
                      [NSArray arrayWithObjects:
                       [[[TTLauncherItem alloc]    
                         initWithTitle:@"Rank"
                         image:@"bundle://defaultMusic.png"
                         URL:@"tt://rank"
                         canDelete:YES] autorelease],nil], nil];

The button is here, no problem. But when clicked, it never opens my RankController class. Here is its source :

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *开发者_JAVA技巧)nibBundleOrNil
    {
        if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
        {
            self.title = @"Rank";
            self.variableHeightRows = YES;
        }

        return self;
    }

- (void)dealloc
{
    [super dealloc];
}

- (void) createModel
{
    NSLog(@"rank");
    self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
                       @"Items",
                       [TTTableTextItem itemWithText:@"Item n°1" URL:nil],
                       [TTTableTextItem itemWithText:@"Item n°2" URL:nil],
                       [TTTableTextItem itemWithText:@"Item n°3" URL:nil],
                       [TTTableTextItem itemWithText:@"Item n°4" URL:nil],
                       [TTTableTextItem itemWithText:@"Item n°5" URL:nil],
                       nil];

}

I tried to proceed the same way that the examples packaged in Three20, so what am I doing wrong ?

Thanks in advance


You need to implement the TTLauncherViewDelegate. In your .h file, declare your view controller to implement the TTLauncherViewDelegate:

@interface SFLauncherViewController : TTViewController <TTLauncherViewDelegate>

Then in .m file, implement this method:

- (void)launcherView:(TTLauncherView *)launcher didSelectItem:(TTLauncherItem *)item{
    NSLog(@"did select item: %@", [item URL]);
    TTNavigator *navigator = [TTNavigator navigator];

    TTURLAction *action = [[TTURLAction actionWithURLPath:[item URL]] applyAnimated:YES];

    [navigator openURLAction:action];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜