Can someone help me figure this out please?
My UITableViewCell textLabel, does not update until I scroll, or touch it.
The ViewController loads, it shows the right amount of cells. But the content is blank. I have to touch it or scroll to make my textLabel appear.
Am I doing something wrong here?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
[[cell textLabel] setFont: [UIFont systemFontOfSize: 32.0]];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSDictionary * data = [self timeForObject: [self.months objectAtIndex:indexPath.row]];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *time = [data objectForKey:@"Time"];
NSString *totalTime = [data objectForKey:@"Total Time"];
NSString * textLabel = [NSString stringWithFormat:@" %@ %@",
time, totalTime];
[[cell textLabel] setText:textLabel];
});
});
return cell;
}
Any help is appreciated
Thank you!
Nuno
EDIT:
A call to [cell setNeedsLayout] fixes this issue. Thank you everyone for your help!