我創建了一個簡單的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 –