我正在尝试根据我在 TableView 中选择的行将数据发送到我的 DetailViewController。我的项目是用 StoryBoard 制作的。
我的 TableViewCell 很好地链接到我的 MainStoryBoard 中的 UIView,一切都很好,但我不知道如何将所选行的信息发送到我的 DetailView
这是我所拥有的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSUInteger oldRow = [lastIndexPath row];
NSString *key = [keys objectAtIndex:section];
detailRow = [names objectForKey:key];
static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SectionsTableIdentifier];
if (cell == nil)
{
CGRect cellFrame = C
GRectMake(0, 0, 300, 65);
cell = [[UITableViewCell alloc] initWithFrame:cellFrame] ;
}
CGRect nameLabelRect = CGRectMake(200, 5, 200, 15);
UILabel *nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect];
nameLabel.tag = kNameValueTag;
[cell.contentView addSubview: nameLabel];
UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
name.text = [[detailRow objectAtIndex:row] valueForKey:@"name"];
cell.imageView.image = [UIImage imageNamed:[[detailRow objectAtIndex:row] valueForKey:@"image"]];
cell.accessoryType = (row == oldRow && lastIndexPath != nil) ?
UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"DetailGrandComptes" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"DetailGrandComptes"])
{
// HERE IS WHERE THE CODE SHOULD BE I GUESS.... !! I HAVE TO DISPLAY AN UIIMAGEVIEW + UILABEL + UIIMAGEVIEW
}
}