Skip to content

Instantly share code, notes, and snippets.

@nicwise
Created May 5, 2011 19:03
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 nicwise/957668 to your computer and use it in GitHub Desktop.
Save nicwise/957668 to your computer and use it in GitHub Desktop.
some sample MT setup code
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;
tabBar = new UITabBarController();
MainView = tabBar.View;
window.AddSubview(MainView);
near = new NearDialogViewController();
map = new MapViewController();
tripLog = new TripLogViewController();
infoPage = new InfoViewController();
timer = new TimerViewController{
TabBarItem = new UITabBarItem("Timer", Resources.Timer, 1)
};
tabControllers = new UIViewController[] {
new UINavigationController(near) {
TabBarItem = new UITabBarItem("Near", Resources.Near, 0)
},
new UINavigationController(map) {
TabBarItem = new UITabBarItem("Map", Resources.Map, 2)
},
timer,
new UINavigationController(tripLog) {
TabBarItem = new UITabBarItem("Trip Log", Resources.TripLog, 3)
},
new UINavigationController(infoPage) {
TabBarItem = new UITabBarItem("Info", Resources.Info, 4)
}
};
tabBar.SetViewControllers(tabControllers, false);
window.MakeKeyAndVisible ();
return true;
}
// and also this , which is called by the same method above (eventually)
public void BuildPhoneUI()
{
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;
tabBar = new UITabBarController();
tabBar.ViewControllerSelected += delegate(object sender, UITabBarSelectionEventArgs e) {
};
MainView = tabBar.View;
home = new HomeDialogViewController();
contacts = new ContactsDialogViewController();
projects = new ProjectsDialogViewController();
mileage = new MileageDialogViewController();
info = new InfoViewController();
DataSource.Instance.RegisterViewControllers(home, contacts, projects);
tabControllers = new UINavigationController[] {
new UINavigationController(home) {
TabBarItem = new UITabBarItem("Home", StockImages.Home, 0)
},
new UINavigationController(projects) {
TabBarItem = new UITabBarItem("Projects", StockImages.Project, 2)
},
new UINavigationController(contacts) {
TabBarItem = new UITabBarItem("Contacts", StockImages.Users, 4)
},
new UINavigationController(mileage) {
TabBarItem = new UITabBarItem("Mileage", StockImages.GasPump, 5)
},
new UINavigationController(info) {
TabBarItem = new UITabBarItem("Info", StockImages.Info, 6)
}
};
tabBar.SetViewControllers(tabControllers, false);
tabBar.ViewControllerSelected += delegate(object sender, UITabBarSelectionEventArgs e) {
if (e.ViewController.TabBarItem.Title == "Home")
{
home.RefreshFromDatastore();
home.NavigationController.PopToViewController(home.NavigationController.ViewControllers[0], false);
}
};
window.AddSubview(MainView);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment