0

I want to set up a textLabel and a detailTextLabel for my table. The textLabel is working properly. However, I couldnt get the detailTextLabel to display the text that I have set. Below 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] autorelease];
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = @"SomeString";
    cell.detailTextLabel.text = @"hello";

    return cell;
}
K Hsueh
  • 610
  • 1
  • 10
  • 19

3 Answers3

1

I have faced similar issue as like @user1829700.

My initial settings are

TableView --> Prototype Cell --> (Attribute Inspector) Style - set to Custom (by design)

Changed Style to - Subtitle, it does the trick

codeMagic
  • 44,549
  • 13
  • 77
  • 93
EditOR
  • 367
  • 3
  • 9
0

Try this Use appropriate UITableViewCellStyle with this (anything but UITableViewCellStyleDefault should thus work). The cell's style is specified when you initialize it.

iAppDeveloper
  • 1,088
  • 1
  • 8
  • 16
0

In your custom table cell implementation try adding @synthesize detailTextLabel;

Header (.h):

@property (nonatomic, weak) IBOutlet UILabel *textLabel;
@property (nonatomic, weak) IBOutlet UILabel *detailTextLabel;

Implementation (.m):

@synthesize textLabel;
@synthesize detailTextLabel;
David Douglas
  • 10,377
  • 2
  • 55
  • 53