2011-08-21 90 views
0

我修改我的应用程序以使用Three20,现在我想使用Three20导航。Three20导航:查看不显示

这里是我的代码,在此之前,完美的作品:

ENSListViewController *vc = [ENSListViewController alloc]; 
NSArray *ensArray; 
NSDictionary *dic; 
NSInteger folder_id; 
NSString* folder_type; 
NSString* barTitle; 
NSString* folderName; 

if (indexPath.section == 0) 
{ 
    ensArray = [ensFolderList objectForKey:@"an"]; 
    dic = [ensArray objectAtIndex:indexPath.row]; 
    folder_type = @"an"; 
    barTitle = [NSString stringWithFormat:@"%@", [dic objectForKey:@"name"]]; 
    folder_id = [[dic objectForKey:@"ordner_id"] intValue]; 
    folderName = [dic objectForKey:@"name"]; 
} 
else 
{ 
    ensArray = [ensFolderList objectForKey:@"von"]; 
    dic = [ensArray objectAtIndex:indexPath.row]; 
    folder_type = @"von"; 
    barTitle = [NSString stringWithFormat:@"%@", [dic objectForKey:@"name"]]; 
    folder_id = [[dic objectForKey:@"ordner_id"] intValue];                   
    folderName = [dic objectForKey:@"name"]; 
} 

vc.folder_id = folder_id; 
vc.folder_type = folder_type; 
vc.barTitle = barTitle; 
vc.folderName = folderName; 
[vc initWithNibName:@"ENSListViewController" bundle:nil]; 
[self.view addSubview:vc.view]; 

它完美。 它分配一个ViewController,在ViewController(Properties)中设置很多数据,然后显示视图。

这里是现在我的代码:

NSArray *ensArray; 
NSDictionary *dic; 
NSInteger folder_id; 
NSString* folder_type; 
NSString* barTitle; 
NSString* folderName; 

if (indexPath.section == 0) 
{ 
    ensArray = [ensFolderList objectForKey:@"an"]; 
    dic = [ensArray objectAtIndex:indexPath.row]; 
    folder_type = @"an"; 
    barTitle = [NSString stringWithFormat:@"%@", [dic objectForKey:@"name"]]; 
    folder_id = [[dic objectForKey:@"ordner_id"] intValue]; 
    folderName = [dic objectForKey:@"name"]; 
} 
else 
{ 
    ensArray = [ensFolderList objectForKey:@"von"]; 
    dic = [ensArray objectAtIndex:indexPath.row]; 
    folder_type = @"von"; 
    barTitle = [NSString stringWithFormat:@"%@", [dic objectForKey:@"name"]]; 
    folder_id = [[dic objectForKey:@"ordner_id"] intValue];                   
    folderName = [dic objectForKey:@"name"]; 
} 


/* 
vc.folder_id = folder_id; 
vc.folder_type = folder_type; 
vc.barTitle = barTitle; 
vc.folderName = folderName; 
[vc initWithNibName:@"ENSListViewController" bundle:nil]; 
//[self.view addSubview:vc.view]; 
*/ 
NSString *url = [NSString stringWithFormat:@"tt://ensList/%@/%@/%d/%@/%@/%@", @"ENSListViewController", nil, folder_id, folder_type, barTitle, folderName]; 
TTURLAction *action = [TTURLAction actionWithURLPath:url]; 
[[TTNavigator navigator] openURLAction:action]; 

这是我的导航:

navigator = [TTNavigator navigator]; // create the navigator 
navigator.persistenceMode = TTNavigatorPersistenceModeAll; // and he will save the data :) 

TTURLMap* map = navigator.URLMap; 

[map   from: @"tt://ens" 
    toSharedViewController: [ENSOverviewViewController class]]; 

[map from: @"tt://ensList/(initWithNibName:)/(bundle:)/(folderId:)/(folderType:)/(barTitle:)/(folderName:)" toViewController:[ENSListViewController class] 

过渡:3];

这里是我的新构造方法:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     [self LoadENSList]; 
    } 
    return self; 
} 

- (void) initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil folderId:(NSInteger)folder_id2 folderType:(NSString*)folder_type2 barTitle:(NSString*)barTitle2 folderName:(NSString*)folderName2 
{ 
    self.folder_id = folder_id2; 
    self.folder_type = folder_type2; 
    self.barTitle = barTitle2; 
    self.folderName = folderName2; 
    [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 

} 

所以,如果你读它,在这里:非常感谢!

现在我的问题是:视图无法打开。什么都没发生。 我想我的自制构造函数中有一个错误,即调用我的构造函数的顺序或类似的东西。我从2小时开始,但无法找到错误。

我知道Three20是非常无证的,我没有阐述一个快速的答案,但如果有人有一个想法:请评论或回答。

回答

0

发现解决方案:

1)我忘记了我的构造者的返回值。 添加后(改变(void)为(id)并添加“return self”)它继续...

2)在他改变1)后,系统崩溃,因为initWithNibName抛出一个NSInvalidArgument错误。 将其更改为init后,它可以很好地工作