I have a UIScrollView in a UIViewController view that scrolls horizontally. How can I detect whether the scroll is at the left end or right end or somewhere in the middle?
A:
GameBit is correct here, but to elaborate -
The UIScrollView has a member variable contentOffset, that describes how many pixels from the origin the scrollview has scrolled. A positive value is a scroll to the right, negative is a scroll to the left.
Is your UIScrollView in Paged mode? if so this will help:
CGFloat pageWidth = scrollView.frame.size.width;
int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
fogelbaby
2010-09-26 13:46:24
A:
Hi Ive tried getting scrollView.contentOffset.x in scrollViewDidScroll: . but it always returns 0. and no my UIscrollview is not in paged mode
Rupert
2010-10-05 10:07:15
sorry my bad i was NSloging an in for xontentOffset.x
Rupert
2010-10-05 10:40:22