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?
I did, but didnt get much success.
wolverine
2009-12-04 09:12:13
The method i mentioned above should do it for you.
Chintan Patel
2009-12-04 09:26:51
+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
2009-12-04 09:02:34
I can know that when i stopped dragging. But how to make the scrolling also stop at that instant?
wolverine
2009-12-04 09:24:37
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
2009-12-04 09:26:21
You can call this method in touchesEnded and pass "NO" for willDecelerate parameter. Like this: [self scrollViewDidEndDragging:scrollView willDecelerate:NO];
Chintan Patel
2009-12-04 09:34:03
- (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
2009-12-04 09:59:33
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
2009-12-04 10:10:21
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
2009-12-07 06:27:54
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
2009-12-07 07:20:33