samedi 25 avril 2015

Getting app freeze and cell becomes empty when prepareForReuse used


I have tried prepareforreuse but now my app getting stuck while scrolling and cell is empty. Is there any wrong I'm doing? please help. All my subviews are added in 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;


Aucun commentaire:

Enregistrer un commentaire