Luca
Luca

Reputation: 20919

detailTextLabel is not working

I know this issue was posted before, and i fixed my code according to their correction, but still not getting the detail of the cell working, only the main text. here is my code:

- (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];//It's well initialized
}
cell.textLabel.text=[myArray objectAtIndex:indexPath.row];
        cell.detailTextLabel.text=@"All the stores";

return cell;
}

What i am supposing to see, is a text and a detail text. However, i only see the main text. Thanx in advance.

Upvotes: 0

Views: 787

Answers (1)

Chris Trahey
Chris Trahey

Reputation: 18290

It is possible that the storyboard contains a prototype cell with the same reuse identifier, and it is configured to be a different style (i.e. to not have a subtitle). For effective debugging, you could remove the call for the tableview to give you a dequeued cell, and freshly instantiate one every time to see if your fresh cell is working. However, I recommend going the other way, and configuring a prototype cell in the storyboard, and using it's config (possibly even raising an exception if it is not present).

Upvotes: 2

Related Questions