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;
NSS开发者_开发问答tring* 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.
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
精彩评论