views:

352

answers:

1

I'm trying to create an application for the iPhone with a table of categories. If I select a category it will display a UIImage. However, I've been looking into it and I'm not sure exactly what to do. Can anyone lend a hand?

+1  A: 

It sounds like the easiest solution would be to use a UITableView in a Navigation Based Application. (Apple has samples on how to use this)

Load the table with your categories.

When the user selects a category, push a new View from a Nib file onto the navigation stack.

This will allow you to use the same Nib for all categories and you just pass the image to load to the class, which handles loading it into a UIImageView.

For example:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];

imageCatView *catView = [[imageCatView alloc] initWithNibName: @"imageCatView" bundle: nil];
catView.categoryID = [[[categories objectAtIndex: _selectedRow] objectForKey:@"CatID"] intValue];

[[self navigationController] pushViewController:catView animated:YES];
[catView release];
}
kdbdallas