Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass scroll event from uibutton to uiscrollview

i have horizontal UIScrollView which is extended from UIScrollView and i added UIButtons horizontally. i can only scroll out of the buttons area, but if i want to scroll over any buttons is fires UIControlEventTouchUpInside event. I don't want this. i want to fire UIControlEventTouchUpInside action if i click and i want to scroll if i scroll.

so how can i pass scroll event from UIButton to UIScrollView?

like image 873
ysnky Avatar asked Sep 17 '10 08:09

ysnky


2 Answers

Subclass UIScrollView, return YES in the - touchesShouldCancelInContentView: method.

like image 99
Mr. Míng Avatar answered Dec 05 '22 06:12

Mr. Míng


that functionality is already built in. When you have a UIControl element as a subview of a scroll view and a touch event is detected, it is initially passed to the UIScrollView. IF, after a moment or two there hasn't been sufficient movement in the touch event, it gets passed on to the button.

like image 45
Eytan Avatar answered Dec 05 '22 07:12

Eytan