uibutton - Detect a touch on a subview in a main controller -
i have main view controller class contains uiscrollview
, number of subviews cards.
each card object , covered uibutton
. want detect tap on uibutton
, want disallow taps on multiple cards @ time.
i understand question partially . see if following helpful :
in scroll view :
(int i=0;i<array;i++) { uibutton *button=[[uibutton alloc]initwithframe:cgrectmake(scrollwidth, 5,50,40)]; button.userinteractionenabled=yes; uitapgesturerecognizer *rcognizer=[[uitapgesturerecognizer alloc]initwithtarget:self action:@selector(buttonselcted:)]; [button addgesturerecognizer:rcognizer]; [scrollview addsubview:button]; scrollwidth=scrollwidth+80; }
in buttonselected method following :
-(void)buttonselected:(uitapgesturerecognizer *)recognizer { uibutton *selecteditem=(uibutton*)recognizer.view; //do want button }
Comments
Post a Comment