0
我有表格單元格顯示正確的數據,但後來做了一個自定義單元格和類,以便我可以更多地控制佈局......但我無法獲得我的自定義單元格顯示數據..它只是顯示標籤與他們的佔位符文本...我錯過了什麼?UITableView自定義單元格不顯示核心數據
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.results.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellResults";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
ResultsCell *resultscell = (ResultsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSManagedObject *result = [self.results objectAtIndex:indexPath.row];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM dd, yyyy"];
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
NSString *eventDate = [dateFormatter stringFromDate:[self trialDate]];
// formatting
resultscell.labelEventDesc.numberOfLines = 0;
// populate the cells
[resultscell.labelEventDesc setText:[NSString stringWithFormat:@"%@",[result valueForKey:@"eventdesc"]]];
[resultscell.labelWeeksOut setText:[NSString stringWithFormat:@"%@",[result valueForKey:@"weeksout"]]];
[resultscell.labelEventDate setText:[NSString stringWithFormat:@"%@",eventDate]];
return cell;
}
現貨!令人驚訝的是,你如何看待一段代碼永遠只需要另一雙眼睛就能看到明顯的東西。非常感謝...完美的作品。 – Mark