3

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?

Frankrockz
  • 594
  • 1
  • 6
  • 24

2 Answers2

2

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

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
  • I tried that, it didn't exactly achieve what I wanted. I'm trying to get each service its own page in a sense but keep them aligned just as they are and snap into place when its aligned with the triangle. – Frankrockz Apr 20 '11 at 15:31
  • @Magician: You have to play around with the content offset. Here's another example: http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/ – sudo rm -rf Apr 20 '11 at 15:59
  • @Magician By accepting my answer I hope you figured out how to do it. If you're feeling nice you could always post the code in your question so others can benefit from it. – sudo rm -rf Apr 23 '11 at 14:31
  • @Magician: Looks like you figured it out, but I found a class that can be used in the future to achieve something similar. – sudo rm -rf May 02 '11 at 18:11
0

I think you can use:

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView

And then check the scrollView.contentOffset.x and compare it to the position of your cloud.

You might get creative so that if the offset is between +/-10 of the cloud position is automatically animates itself to "click" into position above the cloud

chilitechno.com
  • 1,575
  • 10
  • 12
  • I have tried to log the contentOffset but it returned 0 half the time and null half the time. And getting it to snap into position is exactly what I want to do as well as play a sound. Do you happen to have any sample code on completing the snapping and locating of each image? – Frankrockz Apr 19 '11 at 15:39