2

I made a table where I used the customcell in the table.

In the cell there are two buttons.

  1. Detail
  2. Available.

When a user clicks the detail button I want the thumb image to appear in the Imageview of the selected row(cell) to the other view.

When a user clicks the button the user is pushed to another view.

Please help me; how do I get the thumb image into other UIViewcontroller?

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114
ios developer
  • 3,363
  • 3
  • 51
  • 111

2 Answers2

1

One way would be to add a method to your detail view that takes the image as a parameter for example: in your header (If your class is called DetailViewController) and assuming you have a UIImageView on the detail page.

-(DetailViewController *) initWithImage:(UIImage *)image;

in your implementation:

-(DetailViewController *) initWithImage:(UIImage *)image
{
    self = [super init];
    if (self) 
    {
       self.imageView.image = image;
    }

    return self;

}

and to use that method:

DetailViewController* dvc = [[DetailViewController alloc] initWithImage:myImage];
[myNavigationController pushViewController:dvc animated:YES];
[dvc release];  //Don't leak 
cdasher
  • 3,083
  • 1
  • 19
  • 20
1

In the other UIViewController that you are pushing, add a UIImageView to the XIB file of your view and link it up to something like this:

@property (nonatomic, retain) IBOutlet UIImageView *thumbImageView;

Then when you are pushing your view, set your UIImageView after you push the new view controller.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    AnotherViewController *anotherViewController = [[AnotherViewController alloc] init];
    [self.navigationController pushViewController:anotherViewController animated:YES];
    anotherViewController.thumbImageView = [tableView cellForRowAtIndexPath:indexPath].imageView; 
    [anotherViewController release];
}
Chris Ballinger
  • 796
  • 8
  • 20