UITableView cell上的button和label问题
2013-12-06 10:57
225 查看
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;
}
在每次赋值之前,要先清空之前赋的值,才能不会重用,不然会有重用问题的出现
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;
}
在每次赋值之前,要先清空之前赋的值,才能不会重用,不然会有重用问题的出现
相关文章推荐
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题
- UItableView Cell 高度自适应--随着多个label内容变化自适应
- UITableView 的cell重叠问题
- cell中button怎么得到对应cell的indexpath 以及关于UITableViewCellContentView的问题
- Ios 该图显示其出现的相关问题定义UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- iOS UITableView-FDTemplateLayoutCell框架 cell重叠 高度返回0.5问题解决
- 好奇怪的问题! uitablecell中的uiimageview ,有的响应gesture recognizer,有的不响应
- UITableView 的 cell显示不完整的问题
- 关于 UITableView 中 cell 自适应高度的问题
- 关于UITableView中cell的重用问题
- IOS-52-UITableView中cell分割线左对齐(解决iOS8版本适配问题)
- UITableView cell复用出错问题 页面滑动卡顿问题 & 各杂七杂八问题
- UITableView reloadData后,cellForRowAtIndex方法未调用问题
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行的问题
- Ios 自定义表示图出现的相关问题UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- 【控件】UITableView自定义cell时,设置控件frame问题
- UITableView和UICollectionView的cell重用问题
- UITableView使用selectRowAtIndexPath不能默认选中cell的问题
- UITableView 的  cell显示不完整的问题