I am trying to load different nibs into a single UITableView depending on a variable within a model. I seem to have something that looks logical and doesn't crash, however, only 1 of the xibs is being loaded and displayed.
Controller Method:
private void populateTableData()
{
liveTipsTableView.RegisterNibForCellReuse(UINib.FromName("LiveTipCell_", null), "LiveTipCell_");
liveTipsTableView.RegisterNibForCellReuse(UINib.FromName("NewsCell_", null), "NewsCell_");
setListViewSource();
Refresh();
AddRefreshControl();
Add(liveTipsTableView);
liveTipsTableView.Add(RefreshControl);
}
TableSource Method
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var localTip = _tips[indexPath.Row];
if (localTip.NewsItem)
{
CellIdentifier = new NSString("NewsCell_");
NewsCell_ cell = new NewsCell_();
cell = tableView.DequeueReusableCell("NewsCell_") as NewsCell_;
var views = NSBundle.MainBundle.LoadNib("NewsCell_", cell, null);
cell = ObjCRuntime.Runtime.GetNSObject(views.ValueAt(0)) as NewsCell_;
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.BindDataToCell(localTip);
return cell;
}
else
{
CellIdentifier = new NSString("LiveTipCell_");
LiveTipCell_ cell = new LiveTipCell_();
cell = tableView.DequeueReusableCell("LiveTipCell_") as LiveTipCell_;
var views = NSBundle.MainBundle.LoadNib("LiveTipCell_", cell, null);
cell = ObjCRuntime.Runtime.GetNSObject(views.ValueAt(0)) as LiveTipCell_;
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.BindDataToCell(localTip);
return cell;
}
}
I have 2 separate Xib files and they have their own classes which work to populate the views. They all seem to getting used when debugging, it's just a case of the table view is only displaying 1 of these items.
Thanks in advance and please let me know if you need more information to see what's going on.