views:

83

answers:

2

I want the image to move only when i am moving it. When i swipe and take the finger off, it shouldnt move on its own. How can i do this?

A: 

Try and play with decelerationRate.

Jessedc
I did, but didnt get much success.
wolverine
The method i mentioned above should do it for you.
Chintan Patel
+1  A: 

This is what you are looking for:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate; // called on finger up if user dragged. decelerate is true if it will continue moving afterwards
  • From Apple's Documentation.
Chintan Patel
This is more like it - I didn't look through the delegate protocol
Jessedc
I can know that when i stopped dragging. But how to make the scrolling also stop at that instant?
wolverine
Yes, just have decelerate = NO and its done. PS: I had to recreate Photos app fully for a project without using any external frameworks (Three20 etc) which made me master scroll views. :)
Chintan Patel
You can call this method in touchesEnded and pass "NO" for willDecelerate parameter. Like this: [self scrollViewDidEndDragging:scrollView willDecelerate:NO];
Chintan Patel
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ [self scrollViewDidEndDragging:myScrollView willDecelerate:NO];}- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ }I did like this but to no effect.
wolverine
Ohh... Hmmm... I think you need to also check in the scrollViewDidEndDragging method if(decelerate == NO){ Make it stop by doing something here. } . :)
Chintan Patel
Since I have subcalssed UIScrollView for the touch functions to work, now the touch event methods are inside the subclassed file. So where should I call the function u said and what should be its parameters.Is this correct? [self scrollViewDidEndDragging:self willDecelerate:NO];
wolverine
This seems to be correct though i assume that you are posting here because it didnt work for you. :P. I will send you the source code i have when i am home. Lets hope i remember that. :)
Chintan Patel