Reputation: 2877
just created an UITableView,
trying to display some custom data from an array, but what ever I do, i get no text displayed.
NSLog tell me the right text and right amout but no text in table cell.
here is the code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"test";
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
Upvotes: 0
Views: 230
Reputation: 3793
Always set cell properties (text, images, accessory views, etc) in the
tableView:willDisplayCell:forRowAtIndexPath
delegate method.
UITableView sometimes send a prepareForReuse to the cell after it is returned from
tableView:cellForRowAtIndexPath
which causes the cell to reset it's labels and images.
Upvotes: 0
Reputation: 407
Things to check:
Is cellForRowAtIndexPath
getting called? Put a breakpoint in
Make an array in ViewDidLoad (property, alloc'd) and addObjects @"One", @"Two", @"Three", nil
and then cell.textLabel.text = [theArray objectAtIndex:indexPath.row];
IfcellForRow
is being called, this will show in the cells.
What doesConfigureCell
do? Include the code please.
Also check your tableView delegate methods are being called (NumberofRowsInSection
etc)
Upvotes: 3