UIScrollview zoom and enable paging simultaneously

走远了吗. 提交于 2020-01-01 03:37:28

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6260399/uiscrollview-zoom-and-enable-paging-simultaneously

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!