Suppose I have a scroll view in a view & a scroll view's size is 320 width, 2000 height.
When user scrolls & decelerating stops,
I want to know where a scroll view has stopped?
i.e. at 300px or 400px or at 600px.
Thanks in advance.
Suppose I have a scroll view in a view & a scroll view's size is 320 width, 2000 height.
When user scrolls & decelerating stops,
I want to know where a scroll view has stopped?
i.e. at 300px or 400px or at 600px.
Thanks in advance.
You can find out where any view is situated relative to its superview by looking at its frame rect. What are you trying to do?
When the scroll view is done scrolling, it fires off some events to its UIScrollViewDelegate
:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
You can implement those methods in the delegate to find out the new contentOffset
of your UIScrollView
:
@property(nonatomic) CGPoint contentOffset
you can track that afeter scrolling, what is the coordinate of the origin, using the following two methods. This are two delegate methods conforms to your UIScrollView class.
(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)newScrollView { NSLog(@"scrollViewDidEndScrollingAnimation"); CGPoint p = scrollView.contentOffset;
int curr= floor(p.x/320);
NSLog(@"x=%f,y=%f,curr=%d",p.x,p.y,curr);
} - (void)scrollViewDidEndDecelerating:(UIScrollView *)newScrollView {
[self scrollViewDidEndScrollingAnimation:newScrollView];
}