Adjust iOS scroll vs swipe page sensitivity

We are always keen to improve the Pugpig reading experience. In the past with our product we have had customer and client feedback that pages would often be tricky to swipe left or right onto next page. We made framework changes to improve the overall angle tolerance of the gesture to improve the detection of whether the user wants to swipe horizontally or scroll vertically. This has taken a couple of iterations to perfect, however we appreciate peoples views on the usability or how they use and interact with a page on a device can vary. If you feel our default setting may be too sensitive or not sensitive enough there is a way to adjust this further.

Our scroll view now has a priorityThreshold parameter that can be adjusted. It is not exposed in the public API at this point, so it needs to be adjusted using an NSInvocation (although this will probably change in a future release).

Insert this code into your DocumentViewController's viewDidLoad:

  CGFloat priority = 1.0;
  id psv = [pageControl scrollView];
  SEL spt = @selector(setPriorityThreshold:);
  NSMethodSignature *sigspt = [[psv class] instanceMethodSignatureForSelector:spt];
  NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sigspt];
  [inv setSelector:spt];
  [inv setArgument:&priority atIndex:2];
  [inv invokeWithTarget:psv];

You will also need to add the following after the `#import`s in your file:

@interface KGPagedDocControl ()
@property (nonatomic, retain, readonly) UIScrollView *scrollView;

The default priority is 5.0. If you want it to be more like the older behaviour (which is that the webview is as likely to scroll down as left or right) set the value to 1.0. If you want the webview to be easier to scroll down without accidentally moving to the next or previous page, make the value larger.

In effect, the priority represents the ratio of the horizontal velocity of the gesture from the page control to the vertical velocity of the webview's scroll gesture. You must exceed the threshold before your horizontal scroll is accepted. In other words, the default value of 5.0 means that you must be swiping horizontally 5.0 times faster than vertically before you can move to the next or previous page. If the webview itself cannot be scrolled vertically (because the content isn't high enough) you do not need to exceed this threshold, because your swipe is unambiguous. The minimum value for the threshold is 1.0. At this point, the scroll direction will simply be in the direction with the most velocity (horizontal or vertical).

If you have views on the sensitivity and behaviour or any customer feedback you would like to share please let us know.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


  • Avatar

    pageControl doesn't have a scrollView property

  • Avatar
    Pillar Timi

    Instead of id psv = [pageControl scrollView];
    use id psv = pageControl.subviews[0];

Powered by Zendesk