Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell's DetailTextLabel is null, missing something?

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.

like image 688
Driss Zouak Avatar asked Mar 01 '11 18:03

Driss Zouak


1 Answers

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

like image 118
GendoIkari Avatar answered Sep 18 '22 15:09

GendoIkari