1 // 2 // UITestViewController.h 3 // UITest 4 // 5 6 #import7 8 @interface UITestViewController : UIViewController 9 { 10 11 } 12 13 @end 14 15 16 17 // 18 // UITestViewController.m 19 // UITest 20 // 21 22 #import "UITestViewController.h" 23 24 UIImageView *largeImageView; 25 26 @implementation UITestViewController 27 28 - (void)viewDidLoad { 29 30 [super viewDidLoad]; 31 32 CGRect scrollFrame = CGRectMake(20,90,280,280); 33 UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:scrollFrame]; 34 scrollView.minimumZoomScale = 0.5; 35 scrollView.maximumZoomScale = 2.0; 36 scrollView.delegate = self; 37 38 UIImage *bigImage = [UIImage imageNamed:@"appleLogo.jpg"]; 39 largeImageView = [[UIImageView alloc] initWithImage:bigImage]; 40 41 [scrollView addSubview:largeImageView]; 42 scrollView.contentSize = largeImageView.frame.size; //important! 43 44 [self.view addSubview:scrollView]; 45 46 [scrollView release]; 47 } 48 49 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 50 { 51 return largeImageView; 52 } 53 54 - (void)didReceiveMemoryWarning { 55 // Releases the view if it doesn't have a superview. 56 [super didReceiveMemoryWarning]; 57 58 // Release any cached data, images, etc that aren't in use. 59 } 60 61 - (void)viewDidUnload { 62 // Release any retained subviews of the main view. 63 // e.g. self.myOutlet = nil; 64 } 65 66 67 - (void)dealloc { 68 69 [largeImageView release]; 70 71 [super dealloc]; 72 } 73 74 @end