uibutton - Add UILongPressGestureRecognizer to multiple buttons inside a UIScrollView -


i have 5-10 diffrent buttons inside uiscrollview.

i want add uilongpressgesturerecognizer buttons inside uiscrollview.

-(ibaction)checkifuserwantstodosomething:(id)sender {     holdtimer = [nstimer scheduledtimerwithtimeinterval:1.2 target:self selector:@selector(doaction:) userinfo:nil repeats:no]; }  -(void)doaction:(id)sender {     [holdtimer invalidate];      //my code... } 

you can uiscrollview's subviews, , filter out uibutton's so:

for (uibutton *button in myscrollview.superview.subviews) {     if ([button iskindofclass[uibutton class]]) {      } } 

then can create , add uilongpressgesturerecognizer buttons.

uilongpressgesturerecognizer *holdrecognizer = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(doaction:)]; [holdrecognizer setminimumpressduration:2];  [button addgesturerecognizer:holdrecognizer]; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -