UITableViewCell的DetailTextLabel为null,缺少什么?

时间:2011-03-01 18:42:28

标签: iphone xamarin.ios

我遗漏了一些我怀疑是显而易见的东西,但我找不到它。

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

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

我正在使用DetailTextLabel获取空引用异常。

1 个答案:

答案 0 :(得分:27)

这是因为您使用的是UITableViewCellStyle.Default。如果你想要detailsLabel,你需要UITableViewCellStyle.Subtitle。

相关问题