Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck if a UIScrollVIew's contentOffset is equal to a certain x value
    text
    copied!<p>I have a UIScrollView inside a UICollectionViewCell an I'm trying to perform an action when a UIScrollView scrolls to a certain -x value. </p> <p>I've tried</p> <pre><code>CGPoint lastOffset; if (lastOffset.x &lt; -50 &amp;&amp; scrollView.contentOffset.x &gt;= -50) { // Animate the star NSLog(@"Animate"); } </code></pre> <p>but the problem is that it only gets called when the scrollVIew is returning to its normal state. </p> <p>for the heck of it, I've also tried</p> <pre><code>if (scrollView.contentOffset.x &gt;= -50) { // Animate the star NSLog(@"Animate"); } </code></pre> <p>but this doesn't always get called.</p> <p>Basically, what I am trying to create is something like the pull to refresh, but on the scrollViews's x access. </p> <p>Another example if what I am trying to do is what Tweetbot 3 for iPhone does. If you swipe right on a cell you get the options to reply, star, etc etc. </p> <p>Whats the best way to solve this?</p> <p><strong>Update:</strong> I'm using a UICollectionViewCell. </p> <p>The way the scrollview is set up is something like this:</p> <p><img src="https://i.stack.imgur.com/2P0bc.png" alt="enter image description here"></p> <p>What I'm trying to do is to bring the gutter view in :</p> <p><img src="https://i.stack.imgur.com/EBawD.png" alt="enter image description here"></p> <p>and animate a little star when the scrollView reaches -50 on the x axis. </p> <p>The reason why I'm placing this view and the animating the star in the negative part of the scrollView's content bounds, is to allow the scrollView to snap back into place. </p> <p><strong>Update 2:</strong> I've figured it out. I'll accept my answer soon as I am allowed to. Thanks for everyone's input!</p>
 

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