0

I'm attempting to create a table/grid like view which i can use for displaying large amounts of information.

The way I have attempted to achieve this is by creating a custom cell view. It's basically UINavigationController, which i know is incorrect as it needs to be a UIView in order to add it to the UITableViewCell.ContentView.AddSubView(UiView view).

It looks like this:

enter image description here

Then in my table source GetCell() i have this.

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
    int rowIndex = indexPath.Row;
    Incident _incident = tableData[rowIndex];

    UITableViewCell cell = tableView.DequeueReusableCell(cellID);
    if(cell == null)
        cell = new UITableViewCell(UITableViewCellStyle.Default, cellID);

    CustomCellView content = new CustomCellView();
    content.SetRef(_incident.Id);
    content.SetDescription(_incident.Description);

    cell.ContentView.Add(content);
    return  cell;
}

Its the cell.ContentView.Add is where i'm going wrong? I Just need to add the custom view i created in IB to the cells content.

poupou
  • 43,413
  • 6
  • 77
  • 174
Steven Yates
  • 2,400
  • 3
  • 30
  • 58

2 Answers2

2

I think this answer will help you using Xcode/InterfaceBuilder NIB files with UITableViewCell.

One important thing to remember is that you're (often) re-using cells and they will be in the state where you left them.

So if you add (e.g. Add or AddSubview) and never remove views (or subviews...) each time you reuse a cell then your memory usage will grow over time (and that can happen very quickly while scrolling a table).

Community
  • 1
  • 1
poupou
  • 43,413
  • 6
  • 77
  • 174
0

I figured this out myself. I was not inheriting the correct view.

Steven Yates
  • 2,400
  • 3
  • 30
  • 58