Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Monotouch: UITableViewDataSource
public class MainTableDataSource : UITableViewDataSource
private List<string> _items;
private string _section1CellId;
public MainTableDataSource()
_section1CellId = "cellid";
_items = new List<string>()
"Checked items demo",
"Various styles demo",
"Editable tables demo"
public override string TitleForHeader(UITableView tableView, int section)
return "Items";
public override int RowsInSection(UITableView tableview, int section)
return _items.Count;
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
// For more information on why this is necessary, see the Apple docs
var row = indexPath.Row;
UITableViewCell cell = tableView.DequeueReusableCell(_section1CellId);
if (cell == null)
// See the styles demo for different UITableViewCellAccessory
cell = new UITableViewCell(UITableViewCellStyle.Default, _section1CellId);
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
cell.TextLabel.Text = _items[indexPath.Row];
return cell;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.