views:

271

answers:

4

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.

+1  A: 

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?

NSResponder
+1  A: 

Use scrollview.contentOffset.

Ben Gottlieb
I found it. So, I tried to close / delete this question but I couldn't.
sugar
+3  A: 

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
No Surprises
+1  A: 

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];

}

faisal