誰かがこれを理解するのを手伝ってくれますか?
私のUITableViewCell textLabelは、スクロールするかタッチするまで更新されません。
ViewControllerが読み込まれ、適切な量のセルが表示されます。でも中身は真っ白。textLabel を表示するには、タッチするかスクロールする必要があります。
ここで何か間違ったことをしていますか?
- (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;
}
どんな助けでも大歓迎です
ありがとうございました!
ヌーノ
編集:
[cell setNeedsLayout] を呼び出すと、この問題が修正されます。助けてくれてありがとう!