有人可以告诉我如何使用prepareForReuse吗?我已经搜索了几个小时并阅读了开发文档。
在扩展 UITableViewCell 的自定义单元中,我有prepareForReuse 方法及其被调用,但我该如何处理它(存在渲染问题)。我这样做吗
每个标签的截止日期 = @"" ?
@implementation PostTableCustomCellController
@synthesize authorName;
@synthesize deadline;
@synthesize distance;
@synthesize interestedCount;
@synthesize description;
@synthesize avatar;
@synthesize viewForBackground;
@synthesize fetchedResultsController, managedObjectContext;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void) prepareForReuse {
NSLog(@"prep for reuse");
[self clearFields];
}
- (void) clearFields {
NSLog(@"clearFields was called Jason");
}
- (void)dealloc {
[super dealloc];
}
@end
一旦构造了一个对象,调用任何init
方法是不可接受的,因此必须有某种方法可以在对象被重用之前将其重置回中性状态。就是这样prepareForReuse
是为了.您可以使用该方法将对象恢复到刚执行完之后的相同状态。init
方法被调用,以便调用代码将执行相同的操作,无论是给定一个新对象还是一个重用对象。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)