Priyanka V
Priyanka V

Reputation: 834

UIScrollview zoom and enable paging simultaneously

Can i implement both the paging and zooming of imageview in a uiscrollview at the same time.

Upvotes: 3

Views: 4588

Answers (1)

EmptyStack
EmptyStack

Reputation: 51374

Yes. You can do it. In each page of the mainScrollView add a subScrollView containing the imageView. You need to do the following things.

  1. Set maximumZoomScale 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 imageView.

  2. In the viewForZoomingInScrollView: method of the subScrollView return the imageView

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

    mainScrollView.pagingEnabled = YES;
    

    You have to write further code to handle paging in the mainScrollView.

Upvotes: 18

Related Questions