I suppose you just want to select image by table view.
This is selection table view.
And this is detail view.
At first, I made property arrayImg
.
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
self.arrayImg = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image0.jpg"],
[UIImage imageNamed:@"image1.jpg"],
[UIImage imageNamed:@"image2.jpg"], nil];
}
return self;
}
Then, I wrote the cell selection code.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *s = [NSString stringWithFormat:@"image%d.jpg", indexPath.row];
[self performSegueWithIdentifier:@"showImage" sender:s];
}
At last, I made prepareForSegue
method.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
DetailViewController *d = segue.destinationViewController;
d.strImgName = sender;
}
In the detail view, I just wrote below:
- (void)viewWillAppear:(BOOL)animated
{
self.imageView.image = [UIImage imageNamed:strImgName];
}
The whole project is here:https://github.com/weed/p120801_ImageSelectorWithTableView
You can download sample project and just run it.
I wish my trial is help for you.