When previewing an image on an ipad, if we want to scale and scroll (similar to google maps), we need to use ScrollView
------- View Controller definition:
@ Interface TestBedViewController: UIViewController <UIScrollViewDelegate>
{
UIImage * weathermap;
}
@ Property (retain) UIImage * weathermap;
@ End
@ Implementation TestBedViewController
@ Synthesize weathermap;
// Specify the Image in all the scrollviews when using the zoom gesture.
-(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView
{
Return [self. view viewwithtagag: 201];
}
/*
-(Void) scrollViewDidEndZooming :( UIScrollView *) scrollView withView :( UIView *) view atScale :( float) scale
{
}
*/
-(Void) viewDidLoad
{
// Create a scroll view and set the size and height of the proxy object px py width
UIScrollView * sv = [[UIScrollView alloc] initWithFrame: CGRectMake (0.0f, 0.0f, 3200000f, 284.0f)] autorelease];
Sv. contentSize = self. weathermap. size; // The UIImage object to be scaled.
Sv. delegate = self; // sets the proxy object
// Create an image object
UIImageView * iv = [[UIImageView alloc] initWithImage: self. weathermap] autorelease];
Iv. userInteractionEnabled = YES;
Iv. tag= 201;
// Calculate the zoom Value
Float minzoomx = sv. frame. size. width/self. weathermap. size. width;
Float minzoomy = sv. frame. size. height/self. weathermap. size. height;
Sv. minimumZoomScale = MIN (minzoomx, minzoomy); // the minimum scale to the current ScrollView
Sv. maximumZoomScale = 3.0f; // scale up to three times the image size.
// Add an image in scorllView
[Sv addSubview: iv];
[Self. view addSubview: sv];
}
@ End
Author sdhjob