Skip to content

Instantly share code, notes, and snippets.

@nicwise
Created February 22, 2012 05:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicwise/1881577 to your computer and use it in GitHub Desktop.
Save nicwise/1881577 to your computer and use it in GitHub Desktop.
//most of the non-declared variables here are at the class level - eg window is:
// UIWindow window
// etc.
window = new UIWindow (UIScreen.MainScreen.Bounds);
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;
tabBar = new UITabBarController();
MainView = tabBar.View;
//make some DialogViewController's - I descend various classes off them
summary = new OverviewDialogViewController();
records = new RecordsDialogViewController();
deadlines = new DeadlinesDialogViewController();
export = new ExportDialogViewController();
tabControllers = new UINavigationController[] {
new UINavigationController(summary) {
TabBarItem = new UITabBarItem("Overview", Resources.Overview, 0)
},
new UINavigationController(records) {
TabBarItem = new UITabBarItem("Records", Resources.Records, 1)
},
new UINavigationController(deadlines) {
TabBarItem = new UITabBarItem("Deadlines", Resources.Deadlines, 2)
},
new UINavigationController(export) {
TabBarItem = new UITabBarItem("Export", Resources.Export, 3)
}
};
tabBar.SetViewControllers(tabControllers, false);
tabBar.ViewControllerSelected += delegate(object sender, UITabBarSelectionEventArgs e) {
if (tabBar.SelectedIndex == 0)
{
(summary as OverviewDialogViewController).ReloadSummary(null);
}
};
window.RootViewController = tabBar;
window.MakeKeyAndVisible ();
@ArnoldKrumins
Copy link

Hi do you have the full code listing for this? Specifically the classes?
summary = new OverviewDialogViewController();
records = new RecordsDialogViewController();
deadlines = new DeadlinesDialogViewController();
export = new ExportDialogViewController();

@Shogan
Copy link

Shogan commented Apr 8, 2013

Hi Nic,

Thanks for this example. The only bit I don't understand is:

MainView = tabBar.View;

Where does MainView come from, or where is it supposed to be declared?

Cheers!

@nicwise
Copy link
Author

nicwise commented Apr 9, 2013

@ArnoldKrimins - no, they are just DialogViewController descendants, which is specific to the (client) application. Basically just a UITableViewController.

@Shogan: I think this might be old, dead code. You used to have to keep track of things a bit more aggressively in MonoTouch than you do now, to avoid being GC'ed. I doubt there is any need for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment