Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-15-2009, 11:13 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
starwarsdevwookie59 is on a distinguished road
Default ScrollView Image ZOOM!

I have a scroll view that displays an image. The code below is in the viewdidload section. How in the world do i get it to zoom in? I've tried so many different tutorials and im lost. Anyone know how to zoom on this? Code would be great! Thanks so much!

[scrollView2 setBackgroundColor:[UIColor blackColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.clipsToBounds = YES;
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image0.png"]];
[scrollView2 addSubview:imageView];
[scrollView2 setContentSize:CGSizeMake(imageView.frame.size.wid th, imageView.frame.size.height)];
[scrollView2 setScrollEnabled:YES];
[imageView release];
starwarsdevwookie59 is offline   Reply With Quote
Old 09-14-2009, 11:52 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 3
talk2chris is on a distinguished road
Default

You need to use the delegate method of scrollview to do the zoom action.
talk2chris is offline   Reply With Quote
Old 09-15-2009, 03:42 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 82
smsawant is on a distinguished road
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
I have a scroll view that displays an image. The code below is in the viewdidload section. How in the world do i get it to zoom in? I've tried so many different tutorials and im lost. Anyone know how to zoom on this? Code would be great! Thanks so much!

[scrollView2 setBackgroundColor:[UIColor blackColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.clipsToBounds = YES;
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image0.png"]];
[scrollView2 addSubview:imageView];
[scrollView2 setContentSize:CGSizeMake(imageView.frame.size.wid th, imageView.frame.size.height)];
[scrollView2 setScrollEnabled:YES];
[imageView release];

You need this scroll view delegate UIScrollViewDelegate

this is you .h file
Code:
	IBOutlet UIScrollView *myScrollView;
	UIImageView *myImage;
this is your .m file.

Code:
	UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.austinbull.com/clonemines.png"]]]];
	[self setMyImage:tempImageView];
	[tempImageView release];
	
	myScrollView.contentSize = CGSizeMake(myImage.frame.size.width, myImage.frame.size.height);
	myScrollView.maximumZoomScale = 4.0;
	myScrollView.minimumZoomScale = 0.75;
	myScrollView.clipsToBounds = YES;
	myScrollView.delegate = self;
    [myScrollView addSubview:myImage];
this is working for me.
smsawant is offline   Reply With Quote
Old 09-15-2009, 03:47 AM   #4 (permalink)
Freelance iPhone Dev
 
Join Date: Sep 2009
Location: India
Posts: 71
raz0r is on a distinguished road
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
I have a scroll view that displays an image. The code below is in the viewdidload section. How in the world do i get it to zoom in? I've tried so many different tutorials and im lost. Anyone know how to zoom on this? Code would be great! Thanks so much!

[scrollView2 setBackgroundColor:[UIColor blackColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.clipsToBounds = YES;
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image0.png"]];
[scrollView2 addSubview:imageView];
[scrollView2 setContentSize:CGSizeMake(imageView.frame.size.wid th, imageView.frame.size.height)];
[scrollView2 setScrollEnabled:YES];
[imageView release];

dont release the image view just yet. release it along with the scrollview being released.

Quote:
[scrollView2 setMinimumZoomScale:1.0];
[scrollView2 setMaximumZoomScale:4.0];
[scrollView2 setDelegate:self];
Then add a method to return

Quote:
-(UIView *)viewForZoomingInScrollViewUIScrollView *)scrollview {
return imageview;
}
__________________
Quotes4u2 | Quotes4u | iCheatSheet | Pencil Toons

http://achalaggarwal.com
raz0r is offline   Reply With Quote
Reply

Bookmarks

Tags
scrollview, zoom

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 320
9 members and 311 guests
chiataytuday, coolman, givensur, ipodphone, jbro, mottdog, mtl_tech_guy, Punkjumper, vilisei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,882
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0