Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Sample project with table view which leads to each image view.
Objective-C
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
ImageSelector.xcodeproj
ImageSelector
TableViewController.h
TableViewController.m
readme.md

readme.md

The purpose of this sample project is to select image by table view.

This is selection table view.

selection

And this is detail view.

detail

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];
}
Something went wrong with that request. Please try again.