我有UITableView
其中我想在第一个单元格的第一个单元格中添加背景图像,在第一个单元格上添加图像后,当用户选择任何其他行时,我想隐藏我的背景图像。隐藏取消隐藏UITableViewCell背景
可以吗?
请帮助和提前致谢。
编辑:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath{
if(indexPath.row==0){
cell.backgroundView = [ [UIImageView alloc] initWithImage:[[UIImage imageNamed:@"active-tab.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
flag=true;
NSLog(@"willDisplayCell");
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (flag==true) {
cell.backgroundView = nil; //How to get `cell` here ?
//How to remove BGImage from first cell ???
}
}
你应该包括更多的代码,使我让人们更容易看到你试图做到这一点而不是猜测 –
不要忘记标记最佳答案,并提出帮助你的答案。面临同样问题的人会想知道什么修复了你的问题,而那些花时间回答你的问题的人应该得到声望点 –
我删除了我的downvote,纯粹是因为添加了代码以帮助确定问题。然而,我觉得这个问题还是有点欠缺,下次我会鼓励你把尽可能别人会更容易关闭眼看 –