I’m trying to display some text as a subtitle in my tableView.
Here’s my code for part of the tableView:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } //did the subtitle style
NSUInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
cell.detailTextLabel.text = @"Hello there"; //This is not displaying...
}
}
Is there any reason why I’m not seeing the subtitle text when I run?
You set the
detailTextLabelafter youreturnthe cell. When youreturnthe cell you leave the method. Therefore the last line of code isn’t run.