Skip to content

Instantly share code, notes, and snippets.

@brendanzagaeski
Created August 8, 2013 03:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brendanzagaeski/6181085 to your computer and use it in GitHub Desktop.
Save brendanzagaeski/6181085 to your computer and use it in GitHub Desktop.
A custom RootElement subclass to detect when the TableView has scrolled past "maxRows", and so should load more rows
using System;
using MonoTouch.Dialog;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
namespace MTDialogViewControllerTest
{
public class CustomRootElement : RootElement
{
public CustomRootElement (string caption, Group group) : base (caption, group)
{
}
protected override UIViewController MakeViewController ()
{
return new CustomDialogViewController (this, true) {
Autorotate = true
};
}
}
public class CustomDialogViewController : DialogViewController
{
public CustomDialogViewController (RootElement root, bool pushing): base (root, pushing)
{
}
public override Source CreateSizingSource (bool unevenRows)
{
if (unevenRows)
throw new NotImplementedException ("You need to create a new SourceSizing subclass, this sample does not have it");
return new CustomSource (this);
}
public class CustomSource : DialogViewController.Source
{
public CustomSource (DialogViewController container) : base (container)
{
}
public override void WillDisplay (UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
{
base.WillDisplay (tableView, cell, indexPath);
if (indexPath.Row > maxRows - 20) {
loadMoreRows ();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment