Tab Bar at the Bottom with MonoTouch.Dialog?

淺唱寂寞╮ 提交于 2020-01-02 08:29:32

问题


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!


回答1:


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.




回答2:


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:



来源:https://stackoverflow.com/questions/9297348/tab-bar-at-the-bottom-with-monotouch-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!