how to handle toogle button on every and each on tableviewcell in iPhone

前端 未结 2 1210
小鲜肉
小鲜肉 2021-01-26 13:35

My code is working fine but it works only for a single cell. When i define 5 rows then it works only for the last cell. If I click on 1 cell then value displayimage

相关标签:
2条回答
  • 2021-01-26 13:53

    Take an Array, Store the selected buttons tag in the array and while displaying the button in the cellForRowAtIndex method. check out whether the buttons tag is in that array or not. If its there then show your selected button image else unselected buttons image.

    0 讨论(0)
  • 2021-01-26 14:08

    Try giving the tag for the button as the row number of the table. Then check the tag in the button press method and then perform the logic to change image.

    -(void)changeMapType:(id)sender
    {
       UIButton *button = (UIButton *)sender;
       // Check tag of button
       // Some code
       //Change image after checking
       [button setImage:yourImage forState:UIControlStateNormal];
    
    }
    
    0 讨论(0)
提交回复
热议问题