Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does UIScrollView scroll violently when I quickly swipe twice in the same direction?
    primarykey
    data
    text
    <p>when scrolling horizontally in a UIScrollview, if I quickly swipe twice in the same direction the scroll view jumps violently. Is there anyway to prevent this from happening? To explain in detail, here's an event log from the scrollview where in most delegate methods I just print the x coordinate.</p> <pre><code>scrollViewWillBeginDragging: 14:55:12.034 Will begin dragging! 14:55:12.037 - Position -0.000000 scrollViewWillBeginDeceleration: 14:55:12.129 Deceleration rate 0.998000 14:55:12.152 + Position 314.000000 scrollViewWillBeginDragging: 14:55:12.500 Will begin dragging! 14:55:12.522 - Position 1211.000000 scrollViewWillBeginDeceleration: 14:55:12.530 Deceleration rate 0.998000 14:55:12.533 + Position 1389.000000 scrollViewDidScroll: (printing values &lt; 0 &amp;&amp; &gt; 6000 (bounds.size.width) 14:55:12.595 !!! Position 7819.000000 14:55:12.628 !!! Position 9643.000000 14:55:12.658 !!! Position 10213.000000 14:55:12.688 !!! Position 10121.000000 14:55:12.716 !!! Position 9930.000000 ... contentoffset.x drops with around 400 each scrollviewdidscroll call ... 14:55:13.049 !!! Position 6508.000000 scrollViewDidEndDecelerating: 14:55:13.753 Will end deceleration 14:55:13.761 * Position 6144.000000 </code></pre> <p>The most notable thing in the log is right after scrollViewWillBeginDeceleration when the contentoffset.x jumps with ~6000 points in a matter of milliseconds.</p> <p><strong>Implementation</strong></p> <p>The uiscrollview and uiscrollviewdelegate are in the same class, a subclass of uiscrollview which also implements the uiscrollviewdelegate protocol, nothing special is done to contentoffset, and the only properties set on the scrollview are:</p> <pre><code> self.showsHorizontalScrollIndicator = YES; self.scrollsToTop = NO; self.delegate = self; </code></pre> <p>The scrollview subviews are added once from a viewwillappear call in a uiviewcontroller which hosts the uiscrollview (and the contentSize is set appropriately). Scrolling, waiting a little while, and scrolling again works perfectly.</p>
    singulars
    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.
 

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