Skip to content

Instantly share code, notes, and snippets.

@ybigus
Created August 25, 2013 20:19
Show Gist options
  • Save ybigus/6336052 to your computer and use it in GitHub Desktop.
Save ybigus/6336052 to your computer and use it in GitHub Desktop.
public class CategoryTableSource: UITableViewSource
{
CategoryModel[] _category;
UINavigationController _controller;
public CategoryTableSource (CategoryModel[] category, UINavigationController controller)
{
_category = category;
_controller = controller;
}
public override int RowsInSection (UITableView tableview, int section)
{
return _category.Length;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell("TableCell");
if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Subtitle, "TableCell");
}
//show title
cell.TextLabel.Text = _category [indexPath.Row].Title;
//add accessory
cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;
return cell;
}
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
_controller.PushViewController (new NewsController (_category [indexPath.Row].Id), true);
tableView.DeselectRow(indexPath,false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment