Three20 导航:视图不显示

发布于 2024-12-01 04:52:09 字数 4035 浏览 0 评论 0原文

我重新设计了我的应用程序以使用 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(属性)中设置大量数据,然后显示视图。

现在这是我的代码:

  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]

transition: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 没有文档记录,我并不期望快速得到答案,但如果有人有想法:请发表评论或回答。

I rework my app to use Three20 and I wanna use Three20 navigation now.

Here is my code, that works perfectly before:

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

It works perfectly.
It allocs a ViewController, sets a lot of data in the ViewController (Properties) and then show the view.

Here is my code now:

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

Here is my Navigator:

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]

transition:3];

And here is my new Constructor method:

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

}

So, if you read it up to here: big thanks!

Now my problem is: The view doesn't open. Nothing happens.
I think there is a mistake in my self made constructor, the order of calling my constructor or something like this. Im on it since 2 hours but can't find the error.

I know Three20 is much undocumented and I am not expacting a fast answer, but if anyone have an idea: please comment or answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我早已燃尽 2024-12-08 04:52:09

找到解决方案:

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

2)在他更改 1)后,系统崩溃,因为 initWithNibName 抛出 NSInvalidArgument 错误。
将其更改为init后,它可以完美运行

Found the solution:

1) I forget the return-value in my constructur.
After adding this (changing (void) to (id) and add "return self") it goes on...

2) After he changes in 1) the system crashes because initWithNibName throws an NSInvalidArgument error.
After changing this to init, it works perfectly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文