0
我在創建的UITableViewCell中顯示數據時遇到問題。核心數據單元未正確更新
我有一個CoreData模型,我有一個自定義Cell,我從Xib加載。佈局加載正確,並生成正確數量的單元格。更新button.titleLabel.text和說明時出現問題。
這是我的UITableView和UITableViewCell的相關代碼:
#pragma mark - UITableViewDatasource Methods.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [pointsHistoryItems count];
}
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d",indexPath.row];
PointsHistoryItemCell* cell = (PointsHistoryItemCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return [self createCustomCell:cell cellForRowAtIndexPath:indexPath];
}
- (PointsHistoryItemCell *)createCustomCell:(PointsHistoryItemCell *)cell cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (cell == nil)
{
cell = (PointsHistoryItemCell *)[[[NSBundle mainBundle] loadNibNamed:@"PointsHistoryItemCell" owner:self options:nil] objectAtIndex:0];
}
AwesomePointsHistoryItem *aphi = (AwesomePointsHistoryItem *)[pointsHistoryItems objectAtIndex:indexPath.row];
cell.description.text = aphi.description;
NSString* pointsText = [NSString stringWithFormat:@"%@ Points", [aphi.points stringValue]];
[cell.button.titleLabel setText:pointsText];
NSLog(@"is reaching createCustomCell");
NSLog(@"points %@", cell.button.titleLabel.text);
return cell;
}
日誌打印:
is reaching createCustomCell
points 600 Points
不過。該cell.button.titleLabel.text不更新!
我在做什麼錯?使用
三江源是回答我的問題。 ! – jimbob
然後,你應該接受@ Akhilrajtr的回答... – Moonwalkr
它得到了如此之快的答案,它不會讓我接受。 – jimbob