我已经尝试过prepareforreuse但是现在我的应用程序在滚动和单元格为空时卡住了。 我做错了吗?我的所有子视图都添加在XIB中。
指导我正确的解决方案。
static NSString *cellIdentifier1 = @"pollCell";
IXPollCustomCell *pollCell = (IXPollCustomCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (pollCell == nil) {
pollCell = [[[NSBundle mainBundle] loadNibNamed:@"IXPollCustomCell" owner:self options:nil] objectAtIndex:0];
pollCell.selectionStyle = UITableViewCellSelectionStyleNone;
IXPollCustomCell.m
- (void)prepareForReuse
{
[[self.contentView viewWithTag:2001] removeFromSuperview]; //Does not crash if the view is nil. It's okay to send messages to nil in ObjC
}
IXPollCustomCell.h
@property (weak, nonatomic) IBOutlet UIView *multiChoiceView;
@property (weak, nonatomic) IBOutlet UIView *multiOption1View;
@property (weak, nonatomic) IBOutlet UILabel *choice1RateLabel;
@property (weak, nonatomic) IBOutlet UILabel *color1Label;
@property (weak, nonatomic) IBOutlet UIButton *option1Button;