Created
October 24, 2013 23:36
-
-
Save brendanzagaeski/7147009 to your computer and use it in GitHub Desktop.
TableHeaderView example for MonoTouch.Dialog
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 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