Ios4 TTNavigator在传递参数时未正确打开TTURLMap

Ios4 TTNavigator在传递参数时未正确打开TTURLMap,ios4,three20,ttnavigator,Ios4,Three20,Ttnavigator,我试图通过Three20为iOS传递参数,方法类似于这个问题: 然而,我遇到了一个问题,这个问题并没有解决。我的映射当前设置为 [map from:@"sb://launcher/(initWithAccount:)" toModalViewController:[AccountOverviewViewController class] transition:0]; 为了到达那里,我打电话: NSString *URL = [NSString stringWithFormat:

我试图通过Three20为iOS传递参数,方法类似于这个问题:

然而,我遇到了一个问题,这个问题并没有解决。我的映射当前设置为

    [map from:@"sb://launcher/(initWithAccount:)" toModalViewController:[AccountOverviewViewController class] transition:0];
为了到达那里,我打电话:

    NSString *URL = [NSString stringWithFormat:@"sb://launcher/%@", [@"hey" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
[[TTNavigator navigator] openURLAction:[[TTURLAction actionWithURLPath:URL] applyAnimated:YES]];
然后,在AccountOverviewController中,我有

- (void)initWithAccount:(NSString *)name {
NSLog(name);
}

为了确保我在Console.app输出“hey”时得到了正确的值(我就是这样)。除了一件事,一切都很好,AccountOverviewController从未出现!调用其中的initWithAccount:方法,但它从不在屏幕上显示自己。我是否错过了让控制器获取参数并显示自己的步骤


谢谢。

您的
initWithAccount:(NSString*)name
方法错误。它应该读取
-(id)initWithAccount:(NSString*)name
,并且应该返回self。TTNavigator使用此返回值(它是UIViewController的子代)并将其推送到导航控制器。由于你没有返回任何东西,这纯粹是运气,应用程序没有崩溃,只是没有显示任何东西

Cocoa Touch中以init开头的任何方法使用的模式为:

- (id) initWithSomething:(id)something {
    if (self = [<designated initializer>]) {
        //Do something here.
    }
    return self;
}
-(id)initWithSomething:(id)something{
如果(self=[]){
//在这里做点什么。
}
回归自我;
}
第一行取决于从哪个类生成子类。您总是希望调用指定的初始值设定项。因此,如果您将UIViewController或TTViewController子类化为
[self initWithNibName:nil bundle:nil]

,那么这很好:

NSString *strTTURL = [NSString stringWithFormat:@"tt://PhotoDetail/%@",photoID];
TTURLAction *urlAction=[[[TTURLAction alloc] initWithURLPath:strTTURL] autorelease];
urlAction.animated=YES;
[[TTNavigator navigator]openURLAction:urlAction];