seufagner
seufagner

Reputation: 21

Override UITableViewCell initialized from xib file

I want change some things (hidden a UITextView, change Font color) dinamically when initialize my custom UITableViewCell (from xib file), but initWithStyle selector isn't called.

My code below:

GoalTableCell.h

@interface GoalTableCell : UITableViewCell

  @property (strong, nonatomic) IBOutlet UILabel *fixedText;

  @property (strong, nonatomic) IBOutlet UITextView *editableText;

  @property (strong, nonatomic) IBOutlet UIImageView *imageCircle;

@end

GoalTableCell.m

@implementation GoalTableCell

- (void) setup
{
  self.editableText.hidden = TRUE;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
  if( self = [super initWithStyle:style reuseIdentifier:reuseIdentifier] ) {
    [self setup];
  }

  return self;
}

@end

Upvotes: 1

Views: 315

Answers (1)

Wain
Wain

Reputation: 119031

When any instance is unarchived from a NIB file the 'initWithCoder:method will be called because the archived properties are provided to the instance via thedecoder` parameter.

When instances are loaded from a NIB the awakeFromNib method is also called.

initWithCoder:is called to create the instance.awakeFromNib` is called after the instance has been fully unarchived (outlets are connected) from the NIB.

Upvotes: 3

Related Questions