Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView prevent scrolling in one direction regardless of contentSize/Offset
    primarykey
    data
    text
    <p>I have a UIScrollView with paging enabled but I would like to be able to prevent the user to swipe to the next page or back to the previous page in some cases.</p> <p>For instance someone could be passing a test with ten questions (one question per page) but scrolling won't work unless the person has answered the question at the current page.</p> <p>It could also be to prevent them to swipe back to the previous page. So basically I cannot use directional lock or temporarily disable user interaction because the reader could be allowed to swipe left but not to swipe right.</p> <p>I noticed a few people play around with the content offset but I find that solution ugly because the user can still swipe, it's just that the app automatically readjusts the content offset. I would like it to be as if the view had reached the end of the content or if user interaction was disabled. </p> <p>I guess I could maybe "play" with the content size/offset and refresh it on each page but I am not sure how to do that properly as I also have "links" that can allow someone to jump from one page to another (that could at the time be outside the defined content).</p> <p>I have tried using a custom view for pages where swipe in a specific direction is locked but it doesn't work as I could not find a way to prevent the scroll view from detecting the swipe without affecting pages were swipe should work in a normal way. I saw that I could set that custom view exclusiveTouch property to YES and assumed that since it was going to get all the events I could handle swipes via custom gesture recognizers and forward the events if swipe was allowed or ignore them if not. It did not work, the ScrollView always catches swipe events.</p> <p>I feel I have exhausted every possibility and I cannot find anyone who had similar needs.</p> <p>So I am wondering, is this even possible? If yes, will it require bad hacks or to make a new custom scroll view? </p> <p>Any help/idea would be greatly appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload