2011-08-21 51 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後,它可以很好地工作