Goldberg
Goldberg

Reputation: 19

Object reference not set to an instance of an object[Xamarin, IOS] in UiTable

I am trying to make my custom UITable view show only images from a different class. everything compiles but as soon as the app opens it crashes and tells me "Object reference not set to an instance of an object". Here is my class that is suppose to hold the images : pastebin . com/QDjDVTdm Here is my custom table cell : http://pastebin.com/G3TLMfe4 and here is my table source : http://pastebin.com/xPDuhBeV

And here is how the table is declared in my view controller:

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);

Upvotes: 0

Views: 2368

Answers (1)

Aurast
Aurast

Reputation: 3678

From comments:

You're declaring an array of size 2 (new unclass[2]) but I don't see where you're putting anything in it. So both of the spots in the array will just be null. Put some objects in the array:

lol[0] = new unclass(...);
lol[1] = new unclass(...);

Upvotes: 1

Related Questions