Pinch To Zoom Effect on UIImageView inside scrollView?

后端 未结 6 1129
粉色の甜心
粉色の甜心 2020-12-05 15:05

I\'m using storyboard (iOS 6.0) to create a photo gallery viewer for my app. This is how my imageViewController is set up in storyboard:

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 15:58

    The first step is to make sure your views have the correct delegates implemented. For example in the .m file

    @interface myRootViewController () <.., UIGestureRecognizerDelegate, UIScrollViewDelegate, ...>
    

    From the documentation, make sure you have this implemented:

    The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. 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.

    - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
    {
      return self.fullScreenView;
    }
    
    
    -(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
    {}
    

    The scrollViewDidEndZooming method can stay empty for now. If you already did that or it still doesnt work, please post more of your code and then it is easier to help more specifically.

提交回复
热议问题