Hi all,
I want to re-use a tableview across different sections of a tar bar controller. So I want to basically define only once how the subviews are split up and the logic of how they're built etc. I then want to just be able to pick up this tableview, add the data, and have the table be built when it's being loaded. I want to have custom navigation controller items across each view that has these tableviews. So you might imagine for example, a tableview that has a list of recipes, another instance of that tableview that is the "favorites" section, and another tableview that has a "my custom recipes" section, etc. How is this done best? I could create the tabBarController programmatically in the rootViewController, along with the navigationController, and add the data at the same time there as well, but gathering the data and storing it that "early" in that manner would mean that views that don't even get loaded are using up more memory than is necessary.
i.e. (copied from iOS reference library)
The other option is that I can have multiple classes made that use the same copy & pasted tableview with the same subview logic but use different data. Please advise what the best design practice is.
Darthtroll
I want to re-use a tableview across different sections of a tar bar controller. So I want to basically define only once how the subviews are split up and the logic of how they're built etc. I then want to just be able to pick up this tableview, add the data, and have the table be built when it's being loaded. I want to have custom navigation controller items across each view that has these tableviews. So you might imagine for example, a tableview that has a list of recipes, another instance of that tableview that is the "favorites" section, and another tableview that has a "my custom recipes" section, etc. How is this done best? I could create the tabBarController programmatically in the rootViewController, along with the navigationController, and add the data at the same time there as well, but gathering the data and storing it that "early" in that manner would mean that views that don't even get loaded are using up more memory than is necessary.
i.e. (copied from iOS reference library)
Code:
tabBarController = [[[UITabBarController alloc] init] autorelease];
MyViewController1* vc1 = [[[MyViewController1 alloc] init] autorelease];
MyViewController2* vc2 = [[[MyViewController2 alloc] init] autorelease];
MyViewController3* vc3 = [[[MyViewController3 alloc] init] autorelease];
MyNavRootViewController* vc4 = [[[MyNavRootViewController alloc] init] autorelease];
UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:vc4] autorelease];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, navController, nil];
tabBarController.viewControllers = controllers;
The other option is that I can have multiple classes made that use the same copy & pasted tableview with the same subview logic but use different data. Please advise what the best design practice is.
Darthtroll