UIScrollview scaling and swapping at the same time

Is it possible to simultaneously view and zoom the image in uiscrollview.

+3
source share
1 answer

Yes. You can do it. On each mainScrollView page, add a subScrollView containing the image. You need to do the following.

  • Set maximum ZoomScale for subScrollView

    [subScrollView setMaximumZoomScale:2.0f];   // You can set any value
    

    This value is calculated based on the size of the image displayed in the image.

  • In viewForZoomingInScrollView: the subScrollView method returns imageView

    - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    
        return imageView;
    }   
    
  • Enable paging in mainScrollView

    mainScrollView.pagingEnabled = YES;
    

    You need to write additional code to handle the paging in mainScrollView.

+18
source

All Articles