I have a view that changes if users scrolls it.
I need something to read user's scroll data (direction, force etc.) like UITableView
does it.
if user touches screen and moves finger to the upwards view need to recieve scroll datas to call redraw method.
How can I receive scroll data?
Asked
Active
Viewed 2,207 times
1
-
What data do you want? Is it ony the direction of scroll? – Shanti K Nov 30 '11 at 10:54
-
1Try this link it will help:- http://stackoverflow.com/questions/2543670/iphone-sdk-finding-the-direction-of-scrolling-in-uiscrollview – Anil Kothari Nov 30 '11 at 12:35
1 Answers
5
Yes you can get both.
To get the direction of scroll you need to implement - (void)scrollViewDidScroll:(UIScrollView *)scrollView
delegate.
int prevValue = 0;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
int percentScrolled = abs((int)ceil((scrollView.contentOffset.y/scrollView.contentSize.height)*100));
if(percentScrolled > prevValue)
NSLog("Scrolling Down");
else
NSLog("Scrolling UP");
prevValue = percentScrolled;
return;
}
Now to get the force or power of scrolling. you actually need to set something called decelerateRate
for your scrollView (or tableView). Refer here.

Srikar Appalaraju
- 71,928
- 54
- 216
- 264
-
It will work if I have a custom view that needs to be redrawed depending on where the users moves finger after he touches screen? – Oleg Nov 30 '11 at 11:22
-
I haven't got a UIScrollView object. I have UIView objects that rotate if user presses and moves finger on the screen (scrolling). So I need something to get scroll data from. – Oleg Nov 30 '11 at 11:35