我创建了一个简单的UITableViewController。我为所有单元格添加了一个cell.imageView.image,但是我使用某些单元格的alpha来隐藏图像。当我向下滚动时,其他单元格开始隐藏图像。我试图通过只关注一个单元来解决这个问题,但随机单元开始隐藏图像时,同样的问题仍然存在。任何帮助将不胜感激。UITableViewCell更新多个图像阿尔法
- (void)viewDidLoad {
[super viewDidLoad];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
cell.imageView.image = [UIImage imageNamed:@"down-arrow.png"];
cell.textLabel.text = [NSString stringWithFormat:@"%lu", indexPath.row];
if (indexPath.row == 2) {
cell.imageView.alpha = 0;
}
return cell;
}
首先,如果您想隐藏某些东西,请使用隐藏的属性(布尔值)而不是alpha。 – Masterfego
cell.imageView.alpha =!(indexPath.row == 2); – 0yeoj
你使用错误的方法Apple iOS提供隐藏和显示属性,那么你为什么使用这种类型的设置alpha。作为@Masterfego –