Reputation: 2480
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:
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.
Upvotes: 0
Views: 729
Reputation: 2480
I figured this out myself. I was not inheriting the correct view.
Upvotes: 0
Reputation: 43553
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).
Upvotes: 2