Correct way to zoom UIScrollView with many images?

389 Views Asked by At

Which is the correct way to zoom an image in a UIScrollView with many images?

In depth, i have a contentView (UIView) with all the UIImageView(s) as subviews.

I'm trying to return the current showed UIImageView in viewForZoomingInScrollView: but this doesn't work :-(

func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
    return imageViews[self.currentIndex]
}
2

There are 2 best solutions below

3
On
- (void)viewDidLoad {

    [super viewDidLoad];

    self.scrollView.minimumZoomScale=0.5;

    self.scrollView.maximumZoomScale=6.0;

    self.scrollView.contentSize=CGSizeMake(1280, 960);

    self.scrollView.delegate=self;

}
0
On

I encountered the same problem where images overlapped on the zoomed one. You need to create a scrollView of sub-scrollviews which hold the imageViews. Then configure zoom on each sub-scrollviews.