UIScrollview同时缩放和启用分页 [英] UIScrollview zoom and enable paging simultaneously
问题描述
我可以同时在uiscrollview中同时实现imageview的分页和缩放。
Can i implement both the paging and zooming of imageview in a uiscrollview at the same time.
推荐答案
是的。你能行的。
在 mainScrollView 的每个页面中添加包含 imageView 的 subScrollView 。您需要执行以下操作。
Yes. You can do it. In each page of the mainScrollView add a subScrollView containing the imageView. You need to do the following things.
-
为 subScrollView设置 maximumZoomScale
[subScrollView setMaximumZoomScale:2.0f]; // You can set any value
此值是根据显示在图像中的图像大小计算出来的。 imageView。
This value is calculated based on the size of the image displayed in the imageView.
在 subScrollView 的 viewForZoomingInScrollView:方法中返回 imageView
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imageView;
}
在 mainScrollView中启用分页
mainScrollView.pagingEnabled = YES;
您必须编写更多代码来处理 mainScrollView 中的分页。 / p>
You have to write further code to handle paging in the mainScrollView.
这篇关于UIScrollview同时缩放和启用分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!