CoreDataでUITableViewを更新しています。起動時に、最初の行が(null)として表示されます。下にスクロールすると、ロードされます。それはちょうど最初に表示されません。最初の行にUITableView(null)が表示されます
- (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] autorelease];
[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
}
// set text for each cell
[cell.textLabel setText: [dataManager getProjectValueForKey: @"Title" atIndex: [indexPath row]]];
[cell.detailTextLabel setText: [[[dataManager getProjectValueForKey: @"pid" atIndex:[indexPath row]] stringByAppendingString: @": "] stringByAppendingString: [dataManager getProjectValueForKey: @"Sponsor" atIndex:[indexPath row]]]];
return cell;
}
dataManager
コアデータとは何ですか?私は、セルが準備が整う前にデータを表示しようとしているので、起動時に遅れているか、何かが遅れているように感じます。しかし、私は知らない。
最初のセルをスクロールして画面に戻すと、適切なテキストが読み込まれますか?また、コアデータの結果をあなたのUITableViewに取り込むためにNSFetchedResultsControllerを調べることもできます。そのユースケースに合わせて設計され、高度に最適化されています。 –
はい、彼らはopで述べたとおりです。私はちょっとこれに新しいです。 –
何が起こっているのか正確に言うのは難しいです。 '-tableView:cellForRowAtIndexPath:'にブレークポイントを設定します。最初に '-getProjectValueForKey:atIndex:'に入って、なぜそれがnilに戻ってくるのかを見てください。 –