Zooming on UIScrollView with paging enabled and multiple images
I Have a UIScrollview
with a UIImageView
inside where I scroll from an image to another.
I used the TapToZoom Apple sample code to implement the zoom but whenever I zoom the scrollview starts from the begining rather than the active image.
Here's a piece of my code :
Init and populate the imageview :
table = [[NSMutableArray alloc] initWithCapacity:7];
for(int count = 1; count <= 7; count++)
{
NSString *fileName = [NSString stringWithFormat:@"image%d.jpg", count];
UIImage *image = [UIImage imageNamed:fileName];
[table addObject:image];
if (image == nil) {
break;
}
imageView = [[UIImageView alloc] initWithImage:image];
imageView.userInteractionEnabled = YES;
imageView.multipleTouchEnabled = YES;
Implement Tap Gesture :
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
The handle开发者_运维问答DoubleTap
method zooms to the center of the the imageView
and brings the scrollview to the begigining of the paging.
I searched a lot about this, but was unable to find a way to zoom on the actual displayed image.
Thanks in advance :)
Checkout the PhotoScroller sample from Apple:
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html
精彩评论