I’m totally new to objective c and iphone development. I’m trying to create an application with three levels: a TabBarView, a TableView, and a plain view. The user starts at the TabBarView, selects one of the two TableViews, and can select one of the listed items to display its details (in the plain view). I’ve found the following code in internet articles to help with this:
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Lightbulb *entry = [self.dataController objectInListAtIndex:[indexPath row]];
DetailsController *dvController = [[DetailsController alloc] initWithNibName:@"DetailsView" bundle:[NSBundle mainBundle]];
[dvController assignModel:entry];
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
}
(LightBulb is a model class I made, DetailsController and DetailsView exist with templated implementations).
This is in the TableViewController. Its called, but doesn’t achieve anything. I have no idea why this is.
What exactly do I have to do in responding to the didSelectRowAtIndexPath event to display a new view? How do I do this in a way that doesn’t hide/interfere with the tab view?
I am assuming that your tab is selecting between two view controllers and if this is the case then “[self.navigationController pushViewController:dvController animated:YES];” will not work because you do not have a navigation controller for that view controller.
You will need to have the structure of having a tabBarViewController where each tab loads a UINavigationController rather than a ViewController. I would suggest learning the basics of a navigation based app which accomplishes the selection from a tableview and then transferring that code to this project when you understand it. This might be a good one for you Navigation tutorial