ios - Detect which button is pressed with an UIButton Array -


i have uibutton array this:

@property (nonatomic, retain) iboutletcollection(uibutton) nsarray *btn_impact_collection; 

and have function:

- (ibaction)impactaction:(id)sender; 

in xib file have 9 button, each button connected btn_impact_collection array referencing outlet collection. touch_inside property of each button connected function impactaction.

now, when button clicked impactaction function called, inside function, how can know button pressed?

thanks in advance answer!

cast sender uibutton class, , give instance of clicked button. don't have xcode me like:

if ([sender ismemberofclass:[uibutton class]]) {     uibutton *btn = (uibutton *)sender;      // can reference title or tag of clicked button further conditional logic if want.     if([btn.currenttitle isequaltostring:@"title of button"])     {         // something.     }     else if(etc...) } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -