Ios UITableView行未使用UITableViewRowAnimationNone重新加载
我有一个UITableView,在它的Ios UITableView行未使用UITableViewRowAnimationNone重新加载,ios,uitableview,Ios,Uitableview,我有一个UITableView,在它的-tableView:didSelectRowatineXpath:方法中,我想更改两个单元格的外观(刚刚选定的单元格和之前选定的单元格)。我使用这种方法: // reload both rows to change appearance if (![indexPath isEqual:activeIndexPath]) { [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject
-tableView:didSelectRowatineXpath:
方法中,我想更改两个单元格的外观(刚刚选定的单元格和之前选定的单元格)。我使用这种方法:
// reload both rows to change appearance
if (![indexPath isEqual:activeIndexPath]) {
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:activeIndexPath, indexPath, nil]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
使用参数UITableViewRowAnimationAutomatic
set,效果非常好:相应的行会以平滑过渡进行更新。但我希望这两行在没有动画的情况下立即更新
我原以为
UITableViewRowAnimationNone
可以解决这个问题,但如果我在行动画中使用该常量,单元格根本不会被更新您在更改什么?数据源?不,单元格的背景视图。如何?如何更改背景视图?在-tableView:cellforrowatinexpath:
方法中,我更改自定义单元格的属性cell.active=YES代码>。在UITableView子类中,我实现了此属性的setter方法:-(void)setActive:(BOOL*)active{((CBTrackCellBackgroundView*)self.backgroundView*)highlighted=active;[((CBTrackCellBackgroundView*)self.backgroundView)setColor];[self.backgroundView setNeedsDisplay];}
我知道这是一个相当不干净的解决方案,但它应该仍然有效。好的,但我的意思是,在didSelectRow中,您只是重新加载表视图行吗?cellForRowAtIndexPath如何知道现在显示为选中的行?