Question

I know its possible to create a table that has an index on the side and a search bar at the top that a user can type in to find an item, but is it possible to say to the table if array isEqual to "item1" push view1? I would like to push a different view with each cell. Anyone have any advice?

Was it helpful?

Solution

Create the cell based on the index path. If you create all the cells ahead of time, store them in an array by row index. If you are creating them as needed, do something like this:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *result;
    switch ( [indexPath row] ) {
    default: result = [self tableView:tableView normalCellForRowAtIndexPath:indexPath]; break;
    case 3: result = [self tableView:tableView detail3CellForRowAtIndexPath:indexPath]; break;
    case 5: result = [self tableView:tableView detail5CellForRowAtIndexPath:indexPath]; break;
    }
    return result;
}

OTHER TIPS

Sure. Just create the appropriate view (controller) depending on the cell's indexPath in tableView:didSelectRowAtIndexPath:.

Check out the sample programs from the book Beginning iPhone Development. You must sign up, but its free. You should look specifically at chapter 9's sample code called Nav. Shows you exactly what you need. This was my first book on the subject and was well worth it.

http://www.iphonedevbook.com/forum/viewforum.php?sid=3010c045df967353c6b3894889e6b8f5

Cheers! Ken

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top