iOS开发。如何扩展UIScrollView的滚动事件响应区域? [英] iOS develop. How to extend UIScrollView's scroll event responding area?

查看:275
本文介绍了iOS开发。如何扩展UIScrollView的滚动事件响应区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启用了 UIScrollView 的分页并设置了 clipToBounds = NO 以便我可以看到当前的外部页面。

I have a UIScrollView's paging enabled and set its clipToBounds = NO so that I can see outside current page.

我想要的是让用户在整个可见区域滚动 UIScrollView ,不仅如此当前页面的一部分。

What I want is to enable the user to scroll the UIScrollView on its entire visible area, not only the part of current page.

我该如何实现?

谢谢。

PS
根据苹果的文档(http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html)中,如果值 pagingEnabled 属性是 YES ,滚动视图在用户滚动时停止在滚动视图边界的倍数上。

P.S. According to apple's documentation (http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html), if the value of pagingEnabled property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls.

这意味着我不能只调整 UIScrollView 以获得我想要的而不影响分页功能,对吗?

This means I cannot just resize the UIScrollView to get what I want without compromising paging functionality, right?

推荐答案

把滚动视图成一个UIView和禁用 clipsToBounds 。 scrollview必须是您想要分页的大小。您将看到滚动视图之外的内容,但分页仍然是相同的。
您可以为外部视图激活 clipsToBounce 以限制滚动视图的大小。

Put the scrollview into a uiview and disable clipsToBounds of the scrollview. the scrollview must be the size you want for paging. you will see the content outside of the scrollview but paging wil still be the same. You can activate clipsToBounce for the outside view to limit the size of the scrollview.

覆盖用于将触摸重定向到滚动视图的视图的 hitTest ...然后您还可以通过触摸滚动视图外部来滚动。

Overwrite the hitTest of the view to redirect the touches to the scrollview... then you will be able to also scroll by touching outside of the scrollview.

这篇关于iOS开发。如何扩展UIScrollView的滚动事件响应区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆