how do i only allow one selected button at once?


how make these buttons 1 can used @ time? im not getting errors right when run btw. im looking solution challenge. help

generated in loop this:

code:
    (int l=0; l<list.length; l++) {                uibutton *abutton = [uibutton buttonwithtype:uibuttontyperoundedrect];          [abutton settag:l];          cgrect buttonrect = cgrectmake(11+charact*20, -40 + line*50, 18, 21);          abutton.frame = buttonrect;                    [abutton addtarget:self action:@selector(buttonclicked:) forcontrolevents:uicontroleventtouchupinside];          [abutton settitle:@" " forstate:uicontrolstatenormal];          [gamescroll addsubview:abutton];  }  
and action when button clicked is:

code:
- (void) buttonclicked:(uibutton *)sender {        int tag = sender.tag;        if (sender.selected == true) {          [sender setselected:false];          [sender setbackgroundcolor:[uicolor clearcolor]];      }      else if (sender.selected == false) {          [sender setselected:true];          [sender setbackgroundcolor:[uicolor redcolor]];      }  }
right works want know if theres button selected , deselect other button, or else automatically deselect time user clicks outside of range of button

in advance
 

"can used" translates button.enabled not button.selected. if want de-select button when button b pressed
code:
[buttona setselected:(!buttonb.selected)]
- olaf
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Has to be the funniest headline ive ever seen

Man Brings Goat to Apple Store and has Pizza Delivered

Elusive Ninja: The Shadowy Thief - Can you survive the fast-paced ninja chaos?