Andrea F
Andrea F

Reputation: 733

Cell text not turning up-UITableView

I have a UITableView within a View Controller. Very strange because the header is showing up and the header text but not the cell text.

- (void)viewDidLoad
{

table.delegate = self;
selection= [[NSMutableArray alloc] init];

[selection addObject:@"text"];
[selection addObject:@"text"];
[selection addObject:@"text"];
...}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// configure the cell in each row

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease]; 
}
NSString *cellValue = [selection objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
//  cell.textColor=[UIColor blackColor];
    return cell;
}

Upvotes: 0

Views: 44

Answers (1)

Chris Loonam
Chris Loonam

Reputation: 5745

Try adding this line

table.dataSource = self;

This way, all the table view data source methods (including cellForRowAtIndexPath:) are called, so long as your class conforms to the UITableViewDataSource protocol.

Upvotes: 1

Related Questions