12

I'm missing something I suspect is obvious but I can't find it.

UITableViewCell cell = tableView.DequeueReusableCell("MyCell");    
if (cell == null) {
        cell = new UITableViewCell(UITableViewCellStyle.Default, "MyCell");
}

cell.TextLabel.Text = "Foo";
cell.DetailTextLabel.Text = "Foo2";

I'm getting a null reference exception with the DetailTextLabel.

Mat
  • 202,337
  • 40
  • 393
  • 406
Driss Zouak
  • 2,381
  • 2
  • 26
  • 39

1 Answers1

36

It's because you are using UITableViewCellStyle.Default. You need UITableViewCellStyle.Subtitle if you want the detailsLabel.

GendoIkari
  • 11,734
  • 6
  • 62
  • 104