Search code examples
iphoneuiscrollviewactionuiscrollviewdelegate

Detecting when a UIScrollView it at a certain point and perform an action


I'm trying to figure out how to do this. Been stuck on this for a really ling time. I'm trying to detect when a UIScrollView is in a perfect location and perform an action. Here I have a UIScrollView aligned with images inside like this. http://cl.ly/66yW now if you look above the first image there is a little triangle. That triangle indicates what action will be performed or only case which URL shortening service will be used. Now when the user scrolls to the next one I'd like to set that service as the service which the URL will be shortened with. http://cl.ly/67cA

How do I go about doing this? Any code or links to complete this are welcomed.

Thanks

Edit: Okay So I gather to get that snapping effect I need paging enabled. Now is it possible for me to set each page its own service like I have in the pictures and keep them all signed lie that so the user can see services fade off the screen like I have it? So like, Rfly.Me is one page, CloudApp is another etc etc etc but also have them lay out exactly as they are shown in the pictures above?


Solution

  • Here's an example that details (mostly) what you're looking for:

    http://code.davidjanes.com/blog/2009/09/26/uipagecontrol-uiscrollview/

    Edit: Just found a drop-in class that does what you're looking for. I'm just posting this here for future reference:

    http://cocoacontrols.com/platforms/ios/controls/v8horizontalpickerview