我在开发tableview自定义单元格时经常遇到这个问题。我有一个tableview,它有很多自定义的单元格(一个UIImageView和UILabel)当用户点击任何这个单元格推新UIViewController和用户填充一些数据,并点击“保存”viewcontroller推回委托方式。UITableview单元格保留自定义图像视图过滤器
在此代理方法中,我检查点击单元格并更改该色调颜色(如选定状态,但我只更改自定义的ImageView色调颜色)。所以这个改变是正确的,但当我滚动任何垂直方向色调消失。下面的图片和代码正确计算出来。
当弹出从委托方法查看控制器(正常工作)
当滚动垂直方向锡
// Custom cell
@interface CustomCell : UITableViewCell
@property(strong, nonatomic) UIImageView *imageView;
@property(strong, nonatomic) UILabel *titleLabel;
@end
// Custom Cell implementation nothing special here.
// UIViewController delegate method when pop back
// I'm filling specific color
@interface UIViewController
@property (strong,nonatomic) CustomCell *myCustomCell;
@end
@implementation UIViewController
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
_myCustomCell = (CustomCell *)[self.tableView dequeueReusableCellWithIdentifier:@"CustomCell" forIndexPath:indexPath];
...
}
- (void)userTappedBackButton {
_myCustomCell.imageView.image = [cell.customImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_myCustomCell.imageView.tintColor = [UIColor colorWithRed:0.27 green:0.58 blue:0.98 alpha:1];
}
@end
谢谢老兄。这就是我需要的。但另一种方法是所有单元的负载都很低。但有时会造成麻烦。 –
经过一些测试后,我发现这不是一个好的选择。 –
我很想知道为什么,以及你最终得到什么解决方案 – bdalziel