3

New to MonoTouch and MonoTouch.Dialog, but I'm sure it's possible to create a tab bar or button bar or what you want to call it - the black bar with icons/buttons at the bottom of the iPhone. Question is how to do it with MonoTouch.Dialog?

Thanks for any help!

poupou
  • 43,413
  • 6
  • 77
  • 174
Johan Danforth
  • 4,469
  • 6
  • 37
  • 36

2 Answers2

9

Here's some code to show how easy it can be:

    class MyViewController : UINavigationController {

        public MyViewController (string s)
        {
            TabBarItem = new UITabBarItem (s, null, 1);
            var root = new RootElement (s) {
                new Section (s) {
                    new StringElement (s)
                }
            };
            PushViewController (new DialogViewController (root), false);
        }
    }

    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {
        window = new UIWindow (UIScreen.MainScreen.Bounds);

        var nav = new UITabBarController ();
        nav.ViewControllers = new UIViewController [] {
            new MyViewController ("a"),
            new MyViewController ("b"),
            new MyViewController ("c")
        };
        nav.CustomizableViewControllers = new UIViewController [0];

        window.RootViewController = nav;
        window.MakeKeyAndVisible ();
        return true;
    }

to give you something like:

screenshot

poupou
  • 43,413
  • 6
  • 77
  • 174
4

You don't do it with MT.Dialog. You would create a UITabBarController, and then assign a view controller to each of it's tabs. Each tab could point to a MT.Dialog DialogViewController, or any other type of ViewController.

Jason
  • 86,222
  • 15
  • 131
  • 146