Created
August 8, 2013 03:00
-
-
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
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
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