Created
April 7, 2011 06:39
-
-
Save azcoov/907167 to your computer and use it in GitHub Desktop.
Example of creating a UIView with MonoTouch.Dialog
This file contains hidden or 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 override bool FinishedLaunching (UIApplication app, NSDictionary options) | |
{ | |
window.AddSubview (navigationController.View); | |
demoRoot = CreateRoot(String.Empty, String.Empty); | |
controller = new DialogViewController (demoRoot) { | |
Autorotate = true | |
}; | |
navigationController.PushViewController (controller, true); | |
window.MakeKeyAndVisible (); | |
return true; | |
} | |
//MonoTouch.Dialog easy way to create a view with the elements api | |
RootElement CreateRoot (String lat, String lng) | |
{ | |
var rootElement = new RootElement ("Location Example"){ | |
new Section ("Latitude/Longitude data", footer){ | |
new StyledStringElement("Latitude", lat), | |
new StyledStringElement ("Longitude", lng) | |
}, | |
new Section() { | |
new StringElement ("Get location", GetLocation), | |
new StringElement ("Clear location", ClearLocation) | |
} | |
}; | |
return rootElement; | |
} | |
//Get the device current location | |
public void GetLocation () | |
{ | |
Util.RequestLocation (newLocation => { | |
controller.Root = CreateRoot(newLocation.Coordinate.Latitude.ToString(), newLocation.Coordinate.Longitude.ToString()); | |
controller.ReloadData(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment