Three20导航:查看不显示

时间:2011-08-21 18:03:01

标签: uiviewcontroller constructor navigation 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很多没有证件,我没有表达快速答案,但如果有人有想法:请发表评论或回答。

1 个答案:

答案 0 :(得分:0)

找到解决方案:

1)我忘记了构造函数中的返回值。 添加此项(更改(void)为(id)并添加“return self”)后,它继续......

2)更改后1)系统崩溃,因为initWithNibName抛出NSInvalidArgument错误。 将此更改为init后,它可以正常工作