I use the Xamarin iOS constructor to create my own TableViewCell class for my TableView. But all the subviews properties of the cell (outlets) return null, except for the cell itself.
My custom cell class:
partial class VehiclesTableCell : UITableViewCell
{
public VehiclesTableCell(IntPtr handle) : base(handle) { }
public void UpdateCell(string licensePlate) {
licensePlateLabel.Text = licensePlate;
}
}
Generated Incomplete Class:
[Register ("VehiclesTableCell")]
partial class VehiclesTableCell
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UILabel licensePlateLabel { get; set; }
void ReleaseDesignerOutlets ()
{
if (licensePlateLabel != null) {
licensePlateLabel.Dispose ();
licensePlateLabel = null;
}
}
}
And GetCell of my source code class:
public class VehiclesTableSource : UITableViewSource
{
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) {
var cell = (VehiclesTableCell)tableView.DequeueReusableCell(new NSString(typeof(VehiclesTableCell).Name));
cell.UpdateCell(LicensePlate);
return cell;
}
}
As we can see, the generated code has an output for licensePlate, so why is its property null? Shouldn't a storyboard automatically create all of its routines? At least this happens in all other situations.

source
share