|
| 1 | +// |
| 2 | +// ImageViewTapViewController.m |
| 3 | +// ImageViewTap |
| 4 | +// |
| 5 | +// Created by Hiroshi Hashiguchi on 11/06/21. |
| 6 | +// Copyright 2011 __MyCompanyName__. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import "ImageViewTapViewController.h" |
| 10 | +#import "ThumbnailView.h" |
| 11 | + |
| 12 | +@implementation ImageViewTapViewController |
| 13 | +@synthesize scrollView; |
| 14 | +@synthesize thumnailView; |
| 15 | +@synthesize imageView; |
| 16 | + |
| 17 | +- (void)dealloc |
| 18 | +{ |
| 19 | + [scrollView release]; |
| 20 | + [thumnailView release]; |
| 21 | + [imageView release]; |
| 22 | + [super dealloc]; |
| 23 | +} |
| 24 | + |
| 25 | +- (void)didReceiveMemoryWarning |
| 26 | +{ |
| 27 | + // Releases the view if it doesn't have a superview. |
| 28 | + [super didReceiveMemoryWarning]; |
| 29 | + |
| 30 | + // Release any cached data, images, etc that aren't in use. |
| 31 | +} |
| 32 | + |
| 33 | +#pragma mark - View lifecycle |
| 34 | + |
| 35 | +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. |
| 36 | +- (void)viewDidLoad |
| 37 | +{ |
| 38 | + [super viewDidLoad]; |
| 39 | + |
| 40 | + NSMutableArray* imageList = [NSMutableArray array]; |
| 41 | + for (int i=0; i < 8; i++) { |
| 42 | + UIImage* image = [UIImage imageNamed: |
| 43 | + [NSString stringWithFormat:@"image%02ds.jpg", i+1]]; |
| 44 | + [imageList addObject:image]; |
| 45 | + } |
| 46 | + self.thumnailView.imageList = imageList; |
| 47 | + CGRect rect = CGRectMake(0, 0, 100*8, 75); |
| 48 | + self.thumnailView.frame = rect; |
| 49 | + self.scrollView.contentSize = rect.size; |
| 50 | + |
| 51 | + [self touchedAtIndex:0]; |
| 52 | +} |
| 53 | + |
| 54 | +- (void)viewDidUnload |
| 55 | +{ |
| 56 | + [self setScrollView:nil]; |
| 57 | + [self setThumnailView:nil]; |
| 58 | + [self setImageView:nil]; |
| 59 | + [super viewDidUnload]; |
| 60 | + // Release any retained subviews of the main view. |
| 61 | + // e.g. self.myOutlet = nil; |
| 62 | +} |
| 63 | + |
| 64 | +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation |
| 65 | +{ |
| 66 | + // Return YES for supported orientations |
| 67 | + return (interfaceOrientation == UIInterfaceOrientationPortrait); |
| 68 | +} |
| 69 | + |
| 70 | +- (void)touchedAtIndex:(NSInteger)index |
| 71 | +{ |
| 72 | + self.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image%02d.jpg", index+1]]; |
| 73 | +} |
| 74 | + |
| 75 | +@end |
0 commit comments