如何使用TTLauncherView启动基于TTTableView的视图? [英] How to launch a TTTableView based view with TTLauncherView?

查看:47
本文介绍了如何使用TTLauncherView启动基于TTTableView的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Three20的新手.我正在尝试创建一个基于TTLauncherView的界面,目前还没有成功.

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

我的LauncherView包含一个映射到URL的按钮.当我单击此按钮时,我希望基于TTTableView的显示在屏幕上.但是我什么都没有.

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.

这是我的AppDelegate代码的一部分:

Here is a piece of my AppDelegate code :

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

还有LauncherView代码(也可以是一段代码):

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];

按钮在这里,没问题.但是单击时,它永远不会打开我的RankController类.这是它的来源:

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 *)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];

}

我尝试以与Three20中打包的示例相同的方式进行操作,所以我做错了什么?

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

预先感谢

推荐答案

您需要实现TTLauncherViewDelegate.在您的.h文件中,声明您的视图控制器以实现TTLauncherViewDelegate:

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

@interface SFLauncherViewController : TTViewController <TTLauncherViewDelegate>

然后在.m文件中,实现此方法:

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];
}

这篇关于如何使用TTLauncherView启动基于TTTableView的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆