UITableView cell上的button和label问题

 int  isGet = [[dic objectForKey:@"IsGet"] intValue];
    if (isGet == 0)
    {
        [cell.takeTaskButton setTitle:@"已完成" forState:UIControlStateNormal];
         cell.completeLabel.text = @"";
        [cell.takeTaskButton setBackgroundImage:nil forState:UIControlStateNormal];
        cell.takeTaskButton.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:15];
        [cell.takeTaskButton removeTarget:self action:@selector(buttonWithGetTask:) forControlEvents:UIControlEventTouchUpInside];
        [cell.takeTaskButton setTitleColor:[UIColor colorWithRed:49.0/255 green:48.0/255 blue:48.0/255 alpha:1.0] forState:UIControlStateNormal];
        cell.takeTaskButton.userInteractionEnabled = NO;
   }
    else if (isGet == 1)
    {
        cell.completeLabel.text = [NSString stringWithFormat:@"%i",times];
        [cell.takeTaskButton setBackgroundImage:Nil forState:UIControlStateNormal];
        [cell.takeTaskButton setTitle:[NSString stringWithFormat:@"进行中  \r\r /%i",Conditions] forState:UIControlStateNormal];
        cell.takeTaskButton.titleLabel.numberOfLines=3;
        cell.takeTaskButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        cell.takeTaskButton.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:12];
        cell.takeTaskButton.titleLabel.textColor  = [UIColor colorWithRed:28.0/255 green:86.0/255 blue:135.0/255 alpha:1.0];
        cell.takeTaskButton.userInteractionEnabled = NO;
        [cell.takeTaskButton removeTarget:self action:@selector(buttonWithGetTask:) forControlEvents:UIControlEventTouchUpInside];
    }
    else if (isGet == 2)
    {

        cell.takeTaskButton.userInteractionEnabled = YES;
        cell.completeLabel.text = @"";
        cell.backgroundColor = [UIColor clearColor];
        [cell.takeTaskButton setSpriteButtonWithHDFile2:@"hall_task_take_btn" HDFloat:P_DISPLAY];
        [cell.takeTaskButton setTitle:@"" forState:UIControlStateNormal];
        [cell.takeTaskButton addTarget:self action:@selector(buttonWithGetTask:) forControlEvents:UIControlEventTouchUpInside];
        cell.takeTaskButton.tag = indexPath.row;
    }

在每次赋值之前,要先清空之前赋的值,才能不会重用,不然会有重用问题的出现
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭