-
-
Save beginor/5525460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TableViewSource<TEntity> : UITableViewSource | |
{ | |
private IList<TEntity> _data; | |
public TableViewSource(IEnumerable<TEntity> data) { | |
this._data = data.ToList (); | |
} | |
public override int RowsInSection (UITableView tableview, int section) | |
{ | |
return this._data.Count; | |
} | |
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) | |
{ | |
var cellIdentifier = GetCellIdentitfier(typeof(TEntity)); | |
var cellView = tableView.DequeueReusableCell(cellIdentifier); | |
// bind data to cell view; | |
return cellView; | |
} | |
// Get cell identifer for Entity type | |
string GetCellIdentitfier (Type type) | |
{ | |
switch (type) { | |
case type1: | |
return "type1-cell-identifier"; | |
case type2: | |
return "type2-cell-identifier"; | |
} | |
return ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ive seen that on the iphone i had before