0

newbie question. Yes, I've looked all over but not found a good explaination of what to do for this particular instance. I'm sure this is very simple but I'm having trouble. If you could spend 5 minutes looking at the code and helping my understanding that would be great.

Ok, I have a custom cell called •cell that I have given the identifier of 'MyCell'. This is filled with detail and works fine. the issue is when I try to pass this to a detail view. I'm struggling to understand the best way to pass this, specifically how to get the text from one part of my custom cell and make this duplicate in the detailView - is the text label meant to be called the same in the custom cell as it is in the detailView or something else? I know that I need to add something to my didSelectRowAtIndexPath, but I'm unsure how to construct this.

My detailViewController is called detailViewController and given the identity detailViewController in the identifier

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // I've called this •cell but my custom cell is called MyCell in the identifier - I'm not sure if this makes a difference?
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

     //then I craete my detailViewController

UIViewController *detailViewController = [[UIViewController alloc] initWithNibName:@"detailViewController" bundle:nil]; // ...

    //I think I understand this bit - detailTitle is the name I have given to the text label in the detail view and venueHeader is the name of the corresponding label in the custom cell - I want the detailTitle to = venueHeader

    detailViewController.detailTitle = CustomCell.venueHeader.text;

     // I have created a segue in storyboards so I don't know if I need this bit of code as well?

     [self.navigationController pushViewController:detailViewController animated:YES];

}
trojanfoe
  • 120,358
  • 21
  • 212
  • 242
Alan
  • 63
  • 7
  • what is the content of the cell ?? – Mutawe Oct 11 '12 at 12:22
  • Hi Jossef - just 4x text labels – Alan Oct 11 '12 at 12:51
  • 1
    Are you dequeueing a reusable cell anywhere? Is this the actual code you are using? Have you created a UITableViewCell xib file for your custom cell? – Greg Price Oct 11 '12 at 14:47
  • Yes to all. I am using the cell prototype for my custom cell - all of that part is working fine. Just looking around am I better using prepareForSegue to pass the data from the table to the detailview? – Alan Oct 11 '12 at 16:05

1 Answers1

0

you can use this code

 UIStoryboard *storyBoard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
DetailViewController *pvc=[storyBoard instantiateViewControllerWithIdentifier:@"DetailViewController"];
pvc.dict = [arrData objectAtIndex:indexPath.row];
 pvc.upload  = [arrData1 objectAtIndex:indexPath.row];

[self.navigationController pushViewController:pvc animated:YES];

than after print dictionary in target view controller to get data

Krutarth Patel
  • 3,407
  • 6
  • 27
  • 54