Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've implemented this method, but it <strong>requires paging enabled</strong>. Lets assume you have five elements <code>A,B,C,D and E</code>. When you set up your view, you add the last element to the beginning and the first element to the end, and adjust the content offset to view the first element, like this <code>E,[A],B,C,D,E,A</code>. In the UIScrollViewDelegate, check if the user reach any of the ends, and move the offset <strong>without</strong> animation to the other end.</p> <p>Imagine the [ ] indicates the view being shown:</p> <pre><code>E,A,B,C,[D],E,A </code></pre> <p>User swipes right</p> <pre><code>E,A,B,C,D,[E],A </code></pre> <p>User swipes right</p> <pre><code>E,A,B,C,D,E,[A] </code></pre> <p>Then, automatically set the content offset to the second element</p> <pre><code>E,[A],B,C,D,E,A </code></pre> <p>This way the user can swipe both ways creating the illusion of an infinite scroll.</p> <pre><code>E,A,[B],C,D,E,A </code></pre> <h2><br></h2> <h2>Update</h2> <p>I've uploaded a <strong>complete implementation</strong> of this algorithm. It's a very complicated class, because it also has on-click selection, infinite circular scroll and cell reuse. You can use the code as is, modify it or extract the code that you need. The most interesting code is in the class <code>TCHorizontalSelectorView</code>.</p> <p><a href="https://gist.github.com/redent/6461423" rel="nofollow noreferrer"><strong>Link to the file</strong></a></p> <p>Enjoy it!</p> <hr> <h2>Update 2</h2> <p><code>UICollectionView</code> is now the recommended way to achieve this and it can be used to obtain the very same behavior. <a href="https://adoptioncurve.net/2013/07/02/building-a-circular-gallery-with-a-uicollectionview/" rel="nofollow noreferrer">This tutorial</a> describes in details how to achieve it.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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