ios - Enabling and disabling multiple buttons in view issue -
i have view 12 buttons. want able perform action's button once when tap , set specific button disabled. when tap on button want same thing happen + set other buttons enabled. there solution?
you can give each button tag, , when tap on button using method viewwithtag
can enable , disable each button:
when create uibutton
, can add:
uibutton *button0 = ... button0.tag = 0; uibutton *button1 = ... button1.tag = 1; //and on
in every action of buttons, must pass id object this:
-(void)tapbuttonone:(id)sender { //with sender can retrive tag of button clicked uibutton *button = sender; int buttontag = button.tag //now can check every button , enable other haven't same buttontag //with first tag = 0 plus 12 last tag 11 i<12 (int = 0; i<12; i++) { //self.view if have added buttons on self.view, otherwise must write view uibutton *buttontemp = (uibutton *)[self.view viewwithtag:i]; if(buttontemp.tag != buttontag) { buttontemp.enabled = yes; } else { buttontemp.enabled = no; } } }
Comments
Post a Comment