Skip to content

Instantly share code, notes, and snippets.

@brendanzagaeski
Created October 24, 2013 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendanzagaeski/7147009 to your computer and use it in GitHub Desktop.
Save brendanzagaeski/7147009 to your computer and use it in GitHub Desktop.
TableHeaderView example for MonoTouch.Dialog
public partial class AppDelegate : UIApplicationDelegate
{
public override UIWindow Window {
get;
set;
}
RootElement MyRootElement;
UIViewController RootViewController;
UINavigationController NavigationController;
public override void FinishedLaunching (UIApplication application)
{
var image = UIImage.FromBundle ("Avatar.png");
Window = new UIWindow (UIScreen.MainScreen.Bounds);
MyRootElement = new RootElement ("Main Menu") {
new Section ("Settings") {
new RootElement ("User information", (root) =>
new CustomDialogViewController (root, image)) {
new Section ("User details") {
new StringElement ("One"),
new StringElement ("Two"),
new StringElement ("Three")
}
}
}
};
RootViewController = new DialogViewController (MyRootElement);
NavigationController = new UINavigationController (RootViewController);
Window.RootViewController = NavigationController;
Window.MakeKeyAndVisible ();
}
}
public class CustomDialogViewController : DialogViewController
{
UIImage Image;
public CustomDialogViewController (RootElement root, UIImage image) : base (root)
{
Image = image;
}
public override void LoadView ()
{
base.LoadView ();
var subView = new UIView (new RectangleF (0, 0, View.Frame.Width, Image.Size.Height + 20));
var imageView = new UIImageView (new RectangleF ((View.Frame.Width - Image.Size.Width) / 2,
10,
Image.Size.Width,
Image.Size.Height));
imageView.Image = Image;
subView.Add (imageView);
TableView.TableHeaderView = subView;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment