Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

I have a custom table cell that is working fine in iOS6.

In iOS5 the app crashes when the screen with the table is navigated to with the error

 *** Assertion failure in -[ThemedTableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:6072

on the following line

 self.titleLabel.shadowOffset = CGSizeMake(0.0, 1.0);

in the awakeFromNib method of a custom UIButton used by one of the table cells.

It seems in iOS5 one of the cells created in cellForRowAtIndexPath is returning nil, and the custom cell's methods such as - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier, and awakeFromNib are not being called.

In the tableview controller I use

nib = [UINib nibWithNibName:@"AboutYouTextFieldQuestionCell" bundle:nil];
[[self tableView] registerNib:nib forCellReuseIdentifier:kTextFieldQuestionCell];

Below is the code used to create the cells

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *questionDict = [self.questions objectAtIndex:indexPath.section];
NSString *questionType = [questionDict objectForKey:@"questiontype"];

if ([questionType isEqualToString:@"textfield"])
{
    AboutYouTextFieldQuestionCell *textCell = [tableView dequeueReusableCellWithIdentifier:kTextFieldQuestionCell];
    textCell.backgroundColor = [UIColor whiteColor];
    textCell.delegate = self;

    NSArray *answersArray = [questionDict objectForKey:@"answers"];
    NSDictionary *questionDictionary = [answersArray objectAtIndex:indexPath.row];
    textCell.questionlLabel.text = [questionDictionary objectForKey:@"questiontitle"];
    NSString *keyString = [questionDictionary objectForKey:@"questionkey"];
    if ([self.aboutYouAnswers objectForKey:keyString]) {
        textCell.tf.text = [[self.aboutYouAnswers objectForKey:keyString] stringValue];
    } else {
        textCell.tf.text = nil;
    }
    return textCell;
}
....
share|improve this question
    
Please, format your code. Also provide code for creating cells. –  Lorenzo B. Feb 19 '13 at 8:34
    
Are you using dequeueReusableCellWithIdentifier:forIndexPath: ? –  borrrden Feb 19 '13 at 8:37
    
Thank borrrden, no, I have just added code used to create the cells –  Greg Feb 19 '13 at 8:41
    
Well what happens if questionType is != textfield? –  Dmitry Shevchenko Feb 19 '13 at 8:41
    
Are you using registerClass:forCellReuseIdentifier:? –  borrrden Feb 19 '13 at 8:43

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.