关闭

UITableView cell上的button和label问题

415人阅读 评论(0) 收藏 举报
 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;
    }

在每次赋值之前,要先清空之前赋的值,才能不会重用,不然会有重用问题的出现
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:10809次
    • 积分:296
    • 等级:
    • 排名:千里之外
    • 原创:19篇
    • 转载:5篇
    • 译文:0篇
    • 评论:0条
    文章存档