Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have custom and very simple UITableViewCell. I just want to init my table view by using new technique in ios 6, i.e. registering class and after deque cell with identifier. So i have UITableViewController, inside the tableview i have one prototype cell , here is the image of it.enter image description here

at first i forgot to register the class in viewDidLoad method inside the Table View controller and it was working fine. here is the code.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCell *cell = [tableView  dequeueReusableCellWithIdentifier:@"customCellIdentifier" forIndexPath:indexPath];

    return cell;
}

but in this case

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

is not called during the cell init process.

and the after i put the register class functionality inside the viewdidload. here is the code

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:@"customCellIdentifier"];

}

after it the - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier starts invoking but in this case the cells are absolutely empty when i'm trying to debug , inside the initwithstyle method all the outlets are nil. whats going on? what i'm doing wrong?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

If you have defined the cell as prototype cell for the table view in your nib/storyboard file, then you don't have to register it, that is done automatically. But in that case, initWithCoder: is called for cells instantiated from the nib/storyboard.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.