objective c - How to change the button colour inside the cell depend upon user selection? -


this button when user select button display colour.

 uibutton *btnclk=[[uibutton alloc]initwithframe:cgrectmake(0, 50, 50, 50)];     [btnclk settitle:@"click" forstate:uicontrolstatenormal];     btnclk.backgroundcolor=[uicolor blackcolor];     [btnclk addtarget:self action:@selector(btnclicked:) forcontrolevents:uicontroleventtouchupinside];     [cell addsubview:btnclk]; 

method:

   -(void)btnclicked:(uibutton *)click {           nsindexpath *ind1=[nsindexpath indexpathwithindex:click.tag];       nsindexpath *ind2=[nsindexpath indexpathwithindex:click.tag];     if(ind1==ind2)     {        btnclk.backgroundcolor=[uicolor colorfromhexstring:@"#ffc400"];     }     else     {         btnclk.backgroundcolor=[uicolor blackcolor];     } } 

the button declaration global.

your ind1 , ind2 same. try compare?

and guess want change code

btnclk.backgroundcolor=[uicolor colorfromhexstring:@"#ffc400"];

to

click.backgroundcolor=[uicolor colorfromhexstring:@"#ffc400"];


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -