【问题标题】:UIButton of UITableViewCell disappear on scrollUITableViewCell 的 UIButton 在滚动时消失
【发布时间】:2014-04-23 15:04:10
【问题描述】:

我的自定义 UItableViewCell 有问题。似乎UITableViewCell 中的所有UIButton 消失scroll 上。 Specilay 在我的 25 号牢房上。有人知道吗?

任何帮助将不胜感激 :)

那一些代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString*  cellIdentifier = @"Cell";

    Cell * __strong cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];


    if (!cell){
        cell = [[Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

    InfoObject __weak *obj = [_pos objectAtIndex:indexPath.row];


    [cell configCell];

    cell.id = obj.id;

    {// EVENT ON BUTTON
        [cell.checkbox addTarget:self action:@selector(checkup:) forControlEvents:UIControlEventTouchUpInside];
        [cell.btnPaymentState addTarget:self action:@selector(changePaymentState:) forControlEvents:UIControlEventTouchUpInside];
    }


    {// SET BUTTON CHECKBOX
        cell.checkbox.tag = indexPath.row;
        [cell.checkbox setImage:[UIImage imageNamed:IMG_BLACK_UNCHECKBOX] forState:UIControlStateNormal];
        [cell.checkbox setImage:[UIImage imageNamed:IMG_BLACK_CHECKBOX] forState:UIControlStateSelected];
        [cell.checkbox setImage:[UIImage imageNamed:IMG_BLACK_CHECKBOX] forState:UIControlStateHighlighted];
    }

    {// SET BUTTON PAYMENT STATE
        cell.btnPaymentState.tag = indexPath.row;
        [cell.btnPaymentState setImage:[self getImageAssociateWithName:obj.stringPaymentState] forState:UIControlStateNormal];
        [cell.btnPaymentState setImage:[self getImageAssociateWithName:obj.stringPaymentState] forState:UIControlStateSelected];
        [cell.btnPaymentState setImage:[self getImageAssociateWithName:obj.stringPaymentState] forState:UIControlStateHighlighted];
    }
    [self SetSelectedBackgroundColorSelectedForFolderCellAtRow:indexPath.row
                                                              :obj.selected Cell: cell];
    [cell.checkbox setSelected:obj.selected];
    [self setCellColorTextOfObjectPrepare:cell withObj:obj];
    return cell;
}

【问题讨论】:

标签: uitableview uiview uiscrollview uibutton


【解决方案1】:

我解决了我的问题。问题是我为我的UIButton 使用 Tagidentifiersame number tag 另一个 UIView 所以当我删除我的UIView 时,UIButton 也会消失。谢谢大家的回答。

【讨论】:

    【解决方案2】:

    删除 if (!cell)

    你可以走了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多