当我选择一行时,会调用此方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[_historyEntryTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
}
从我的 cellForRowAtIndexPath 中,我动态地为 UILabel 设置一个 alpha 值。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *Cell = @"StandardCell";
TWHistoryViewStandardCell *cell =
(TWHistoryViewStandardCell *)[tableView dequeueReusableCellWithIdentifier:Cell];
if (cell == nil) {
cell = (TWHistoryViewStandardCell *)[[[NSBundle mainBundle] loadNibNamed:@"HistoryViewStandardCell" owner:self options:nil] objectAtIndex:0];
}
//...
if (currentPick == PickDateFrom) {
cell.hoursLabel.alpha = 1.0;
} else {
cell.hoursLabel.alpha = 0.7;
}
//...
}
如果从我的 didSelectRowAtIndexPath 方法我在我的表格视图上调用 reloadData,表格将显示更新的单元格,以及预期的 alpha 值。但是 reloadRowsAtIndexPath 没有任何效果。
为什么会发生这种情况?
编辑:
通过在 reloadRowsAtIndexPath 之后调用 reloadData 来“修复锤子”:
[_historyEntryTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[_historyEntryTableView reloadData];
这不是问题的真正答案,但现在可以。
有人知道单元格中是否有某些东西必须被调用才能重新渲染 alpha 值?它只是 UILabel 的 alpha 值,因为文本确实会正确更改。
谢谢!