I have a TableView with CoreData and Custom Cells which all works fine.
now when I select a cell to have its content edited and return from it, by just tapping the back button in a UINavigationController, I have something strange happen.
Please see the images what I mean. It seems that the updated UILabels are being placed on top of the old ones instead of being 'updated'?? Did I miss something??
You will see the difference in the top cell but it happens to all of them.
Edit: Added Code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
customCell = [_mainTableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (customCell == nil)
{
customCell = [[MNCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
CGRect frameTitle;
frameTitle = CGRectMake(20, 4, 195, 21);
CGRect frameSummary;
frameSummary = CGRectMake(20, 25, 250, 30);
CGRect frameDate;
frameDate = CGRectMake(200, 4, 100, 21);
MNotes *mnotes = [[self fetchedResultsController] objectAtIndexPath:indexPath];
//Strings for Title and Summary
titleString = mnotes.noteTitleString;
summaryString = mnotes.mainNoteString;
NSLog(@"TITLE STRING = %@", titleString);
//Date
SORelativeDateTransformer *relativeDateTransformer = [[SORelativeDateTransformer alloc] init];
relativeDate = [relativeDateTransformer transformedValue:mnotes.createDate];
customCell.noteTitle = [[UILabel alloc] initWithFrame:frameTitle];
customCell.noteTitle.backgroundColor = [UIColor clearColor];
customCell.noteTitle.font = [UIFont systemFontOfSize:20];
customCell.noteTitle.userInteractionEnabled = NO;
customCell.noteTitle.textColor = [self colorWithHexString:@"274D70"];
customCell.noteSummary = [[UITextView alloc] initWithFrame:frameSummary];
customCell.noteSummary.backgroundColor = [UIColor clearColor];
customCell.noteSummary.font = [UIFont systemFontOfSize:10];
customCell.noteSummary.userInteractionEnabled = NO;
customCell.noteDate = [[UILabel alloc] initWithFrame:frameDate];
customCell.noteDate.backgroundColor = [UIColor clearColor];
customCell.noteDate.font = [UIFont systemFontOfSize:16];
customCell.noteDate.userInteractionEnabled = NO;
customCell.noteDate.textColor = [self colorWithHexString:@"274D70"]; //#274D70
}
customCell.noteTitle.text = titleString;
customCell.noteSummary.text = summaryString;
customCell.noteDate.text = relativeDate;
[customCell.contentView addSubview:customCell.noteTitle];
[customCell.contentView addSubview:customCell.noteSummary];
[customCell.contentView addSubview:customCell.noteDate];
return customCell;
}