如何使單個單元格轉到不同的視圖控制器。現在,使用我使用的方法,如果我點擊第一個單元格,它會帶我到一個視圖控制器,我有一個圖片。現在,如果我返回並單擊第二個單元格,它會將我帶到相同的視圖控制器。我如何改變這一點,以便所有其他單個單元格都轉到單個視圖控制器?我要添加什麼或配置什麼?如何將單個數據添加到單個單元格?
這裏我的代碼:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSUInteger row = [indexPath row];
cell.textLabel.text = [breakdownArray objectAtIndex:row];
bookDetailViewController.title = [NSString stringWithFormat:@"%@" , [breakdownArray objectAtIndex:row]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
NSInteger row = [indexPath row];
if (self.bookDetailViewController == nil); {
BookDetailViewController *aBookDetail = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:nil];
self.bookDetailViewController = aBookDetail;
[aBookDetail release];
}
bookDetailViewController.title = [NSString stringWithFormat:@"%@" , [breakdownArray objectAtIndex:row]];
Books2010AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.breakdownNavController pushViewController:bookDetailViewController animated:YES];
}