- Select 'View based application' ->Name as 'ZoomDemo'
- open ZoomDemoViewController.h file.and write the below code:
- @interface ZoomViewController : UIViewController
{
IBOutlet UIScrollView *scrollView;
IBOutlet UIImageView *imgView;
}
@property(nonatomic,retain) IBOutlet UIScrollView *scrollView;
@property(nonatomic,retain) IBOutlet UIImageView *imgView;
@end - Open ZoomDemoViewController.m file and synthesize the scrollView and imgView properties.
- @synthesize scrollView,imgView;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SplashScreen.png"]];//WithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.austinbull.com/clonemines.png"]]]];
[self setImgView:tempImageView];
[tempImageView release];
scrollView.contentSize=CGSizeMake(imgView.frame.size.width,imgView.frame.size.height);
scrollView.maximumZoomScale=10.0;
scrollView.minimumZoomScale=0.75;
scrollView.clipsToBounds=YES;
scrollView.delegate=self;
[scrollView addSubview:imgView];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imgView;} - OPen IB and ZoomDemoViewController.xib file and add one UIScrollview from library
and map it with 'file'sowner' . - Add one UIImageView on the UIScrollView and map the imgView to File'sOwner
- Now build and run the app.
Friday, May 14, 2010
How to Zoom In & Out image in IPhone
Wednesday, May 5, 2010
Monday, May 3, 2010
Subscribe to:
Posts (Atom)
