lundi 4 avril 2016

ios check table cell Button while user Select or Deselect cell

Actually I am creating collection of entries using User input. where i want to used Check Box for selection and diselection. instead of checkbox i have used Button where when user select on cell Button image get changed, but when one select again on that cell Nothing Happen. I have tried this.

   - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if([[cell.btn backgroundImageForState:UIControlStateNormal]isEqual:[UIImage imageNamed:@"unchecked.png"]])
        {
            [cell.btn setBackgroundImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
    }

And in didDeselectRowAtIndexPath

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([[cell.btn backgroundImageForState:UIControlStateNormal]isEqual:[UIImage imageNamed:@"checked.png"]])
    {
         [cell.btn setBackgroundImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];

    }
}

Please Help me out where i am stucking.




Aucun commentaire:

Enregistrer un commentaire