0

I have a UIScrollView in the centre of the whole view which is separated in to three parts and scroll horizontally.

Users can scroll the view freely and when the finger is up, i want to set one of the three parts to show based on the contentoffset of the UIScrollView.

how could i detect the touchupinside event in the UIScrollView? I tried add UITapGestureRecognizer and override touchesEnded but it does not work.

Boli-CS
  • 550
  • 1
  • 5
  • 14
  • UIScrollViewDelegate? from the class: - (void)scrollViewDidScroll:(UIScrollView *)scrollView; // any offset changes , also - (void)scrollViewWillEndDragging: – Injectios Nov 24 '15 at 11:31
  • http://stackoverflow.com/questions/9609226/detecting-user-touch-on-uiscrollview have a loot at it. – Muhammad Zohaib Ehsan Nov 24 '15 at 11:32

1 Answers1

0

How about instead using the - scrollViewDidEndDecelerating:?

Keep in mind that just because the user has picked up their finger doesn't mean that the scrollview has stopped changing its content offset. By utilizing the - scrollViewDidEndDecelerating: delegate method, yo will be notified when the scroll view has come to a stop and at that point you can check the contentOffset and do what you need.

- scrollViewDidScroll: isn't a good match for what you want as it gets called even while the user's finger is still down. If that is important to you, then use - scrollViewDidEndDecelerating: as I mentioned above. If you'd rather know when the finger is lifted, and don't care that the scrollview is still in transit, then you can use - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate.

mahboudz
  • 39,196
  • 16
  • 97
  • 124