ios - How to implement checkmark buttons in iPad out side of tableview -


how implement custom checkmark buttons depends on array count, , need allow multiple selection in buttons. i'm used this,

int yaxis = 300; (int x=0; x< [myresultarray count];x++)  {     checkmarkbutton = [uibutton buttonwithtype:uibuttontypecustom];     checkmarkbutton.frame = cgrectmake(100, yaxis, 20, 20);     checkmarkbutton.tag = selectedservicetag;     [self.view addsubview:checkmarkbutton];yaxis = yaxis+30; } 

setting images check mark:

    [checkmarkbutton setbackgroundimage:[uiimage imagenamed:@"checkbox_none"] forstate:uicontrolstatenormal];     [checkmarkbutton addtarget:self action:@selector(serviceselected:) forcontrolevents:uicontroleventtouchupinside]; 

then had implement action method.

     -(void)serviceselected      {          checkmarkbutton.selected = !checkmarkbutton.selected;          if (checkmarkbutton.selected)          {              [checkmarkbutton setbackgroundimage:[uiimage imagenamed:@"checkbox"] forstate:uicontrolstatenormal];          }          else          {              [checkmarkbutton setbackgroundimage:[uiimage imagenamed:@"checkbox_none"] forstate:uicontrolstatenormal];          }      } 

but, @ time of selecting last index button selected.

try code:

check image extension png or jpg

 -(ibaction)serviceselected:(id)sender     {      uibutton *tmpyes = (uibutton *)sender;          if (tmpyes.currentbackgroundimage==[uiimage imagenamed:@"checkbox.png"]) {            [tmpyes setbackgroundimage:[uiimage imagenamed:@"checkbox_none.png"] forstate:uicontrolstatenormal];          }         else         {            [tmpyes setbackgroundimage:[uiimage imagenamed:@"checkbox_none.png"] forstate:uicontrolstatenormal];            }     } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -