mercredi 24 juin 2015

iOS: UIButton background image getting removed for button in custom uitableviewcell on scroll

I have a uibutton in my custom table view cell which has different background image for a button for different cell. As soon as i start scrolling, random cells which were out of scope removes their background image. I have two button with two background image but it is always doing for one of them

Here is an example

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath
PlayerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"playerCell"];
    if(cell == nil) {

        NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PlayerTableViewCell" owner:self options:nil];
        for (id currentObject in topLevelObjects) {
            if ([currentObject isKindOfClass:[PlayerTableViewCell class]])
                cell = (PlayerTableViewCell *)currentObject;
numberImage = [self getUserImage:[self._collectionsNewGame[indexPath.row -1] objectForKey:@"hostBirthday"] isSign:false];
            signImage =[self getUserImage:[self._collectionsNewGame[indexPath.row -1] objectForKey:@"hostBirthday"] isSign:true];
cell.numberButton setBackgroundImage:[UIImage imageNamed:numberImage] forState:UIControlStateNormal];
        [cell.signButton setBackgroundImage:[UIImage imageNamed:signImage] forState:UIControlStateNormal];

Please Help

See more ..

Aucun commentaire:

Enregistrer un commentaire