2015-08-14 46 views
0

我试图让我的自定义UITable视图仅显示来自不同类的图像。一切都编译完成,但只要应用程序打开,崩溃并告诉我“对象引用未设置为对象的实例”。 这里是我的课程,它假设拥有这些图像:pastebin。 COM/QDjDVTdm 这里是我的自定义的表格单元格:http://pastebin.com/G3TLMfe4 这里是我的表源:http://pastebin.com/xPDuhBeV对象引用未设置为UiTable中的对象[Xamarin,IOS]的实例

这里是表是如何在我的视图控制器声明:

unclass[] lol= new unclass[2]; 
UITableView _table; 

_table = new UITableView{ 
    Frame = new CoreGraphics.CGRect(0, 30, View.Bounds.Width, View.Bounds.Height-30), 
    Source = new TableSource(lol) 
}; 
_table.SeparatorStyle = UITableViewCellSeparatorStyle.None; 
_table.RowHeight = UITableView.AutomaticDimension; 
_table.EstimatedRowHeight = new nfloat (15.0); 
View.AddSubview (_table); 
+0

究竟是在哪里引发NullReferenceException?如果调试器已连接,它应该正确地中断引发异常的位置。如果没有附加,日志应该有行号。 – Aurast

+0

它给了我“表源”中的错误,在“cell.UpdateCell(tableItems [indexPath.Row] .imager);”行 行33 – Goldberg

+0

什么行?在调试版本中,崩溃日志中有行号。 – Aurast

回答

1

从评论:

你正在声明一个大小为2的数组(新的unclass [2]),但我没有看到你在哪里放入任何东西。所以数组中的两个点都将为空。在数组中放入一些对象:

lol[0] = new unclass(...); 
lol[1] = new unclass(...); 
相关问题