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;
}
....
dequeueReusableCellWithIdentifier:forIndexPath:
? – borrrden Feb 19 '13 at 8:37registerClass:forCellReuseIdentifier:
? – borrrden Feb 19 '13 at 8:43