I have multiple table views that display different items. The detail view for each cell though should have the same layout. I want to use the same detail view for all the cells of each table without having to implement a different detail view class for each table since it'll pretty much be the same code. How do I do this?
The following method is in one of the table views. This displays the detail view when a cell is selected:
-(void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelectRowAtIndexPath");
AppDelegate *delegate =
(AppDelegate *)[[UIApplication sharedApplication] delegate];
Detail *detail=
[[Detail alloc] initWithIndexPath:indexPath];
[delegate.navController pushViewController:detail animated:YES];
[tv deselectRowAtIndexPath:indexPath animated:YES];
}
The following is the viewDidLoad method in the Detail view class:
- (void)viewDidLoad
{
[super viewDidLoad];
AppDelegate *delegate =
(AppDelegate *)[[UIApplication sharedApplication] delegate];
PokemonInfo *thisPokemon = [delegate.allArray objectAtIndex:index.row];
self.title = thisPokemon.name;
nameView.text = thisPokemon.name;
typeView.text = thisPokemon.type;
attackView.text = thisPokemon.attack;
attackView.editable = NO;
}