Reputation: 1003
Im trying to zoom in a scroll view with multiple images, the scroll view only scrolls vertical, i tried to implement many ways, in many examples but none seens to work. Heres the code im using to create the images and the scroll view:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
for (int i = 0; i < 6; i++)
{
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"amap1%i.png",i+1]];
// create imageView
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, _scrollView.frame.size.height*i, _scrollView.frame.size.width, _scrollView.frame.size.height)];
// set scale to fill
_imageView.contentMode = UIViewContentModeScaleToFill;
// set image
[_imageView setImage:image];
// add to scrollView
[self.scrollView addSubview:_imageView];
}
_scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width, _scrollView.frame.size.height * 6);
_scrollView.bounces = NO;
_scrollView.pagingEnabled = YES;
}
Upvotes: 0
Views: 2010
Reputation: 506
Looks like you'll need to do a UIScrollView (to contain all the images - horizontal scrolling) with a UIScrollView for each image (to zoom in).
There's a WWDC video which talks about how to do this (WWDC 2010 - Session 104; link to iTunes)
Upvotes: 1
Reputation: 752
If you want to implement zoom in an UIScrollView you have to do the following things
zoomEnabled
to YES
Please check the Apple documentation which says:
For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.
Upvotes: 0