Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Taum

macrumors member
Original poster
Jul 28, 2008
56
0
hi,

I've looked thru the docs but can't find a way to set the zoom to an arbitrary value. Am I missing something obvious ?
I'd like the scrollview to zoom in as I double tap it. I can get the double tap but I'm stuck after that.
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
hi,

I've looked thru the docs but can't find a way to set the zoom to an arbitrary value. Am I missing something obvious ?
I'd like the scrollview to zoom in as I double tap it. I can get the double tap but I'm stuck after that.

Just change the scale of the view controlled by the UIScrollView, animating if necessary.
 

Taum

macrumors member
Original poster
Jul 28, 2008
56
0
Thanks for your reply :)
Could you explain a little bit more what you mean by "the scale of the view" ? There is no scale property for UIView, nor could I see anything related in UIScrollView. I did try to change the transform of the view, which almost work, but it sounds like UIScrollView isn't aware of this change.

Here is what I'm doing in my UIScrollView subclass (I'm not interested in animation for now, I just try to set the zoom to 8x and center the view) :
Code:
UIView *v = [self.delegate viewForZoomingInScrollView:self];
int vw = v.bounds.size.width;
int vh = v.bounds.size.height;
CGAffineTransform t = v.transform;
t = CGAffineTransformMakeScale(8, 8);
v.transform = t;
v.center = CGPointMake(vw*4, vh*4);
self.contentSize = CGSizeMake(vw*8, vh*8);
[self setContentOffset:CGPointMake(vw*4, vh*4) animated:NO];
			
[self.delegate scrollViewDidEndZooming:self withView:v atScale:8];

When I double tap, it does zoom to 8x and I can pan, but if I zoom in or out using pinching it breaks as if the UIScrollView didn't knew I changed the scale myself (and how should it know, unless it checked v.transform before zooming ?). Did I miss something ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.