Reputation: 5044
I have a program that has a list of information that when tapped it needs to take you a screen to get more information about that item. I don't know if I need to use a Table View Controller or a Navigation Controller.
What would you recommend and why? What are the differences between the two?
Upvotes: 0
Views: 2030
Reputation: 235
UINavigationController is a 'container' controller. Meaning, it houses other view controllers inside of it. So if you wanted a UITableviewController inside a UINavigationViewController you could make it as such:
[[UINavigationController alloc]initWithRootViewController:yourTableView];
Then when you select the item from the table that you wish to show new information, you will 'push' a new view controller onto the the UINavigationController stack:
[self.navigationController pushViewController:nextView animated:YES];
This can be done inside the
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
function of your UITableViewController. It will create the toolbars at the top for you, as well as the backwards navigation buttons that are expected.
This link is to the apple documentation that explains the types of view controllers, and it is definitely worth the read.
Upvotes: 2
Reputation: 6679
You need to use a table view controller inside a navigation controller. The table view controller would provide your list of items. Then you push a normal view controller, using the UINavigationController
when you want to show more information.
Upvotes: 1
Reputation: 118731
You need to use both. A UITableViewController will display a list of items, and a UINavigationController will let you go to a secondary ("detail") screen.
Read the View Controller Programming Guide for more information.
Upvotes: 1