Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS develop. How to extend UIScrollView's scroll event responding area?

Tags:

ios

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

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

How can I implement this?

P.S. According to Apple's documentation (https://developer.apple.com/documentation/uikit/uiscrollview), if the value of pagingEnabled property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls.

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

like image 647
AKFish Avatar asked Aug 07 '11 13:08

AKFish


1 Answers

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.

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.

like image 189
Bastian Avatar answered Oct 18 '22 16:10

Bastian