<tfoot id='B5FcP'></tfoot>
  1. <i id='B5FcP'><tr id='B5FcP'><dt id='B5FcP'><q id='B5FcP'><span id='B5FcP'><b id='B5FcP'><form id='B5FcP'><ins id='B5FcP'></ins><ul id='B5FcP'></ul><sub id='B5FcP'></sub></form><legend id='B5FcP'></legend><bdo id='B5FcP'><pre id='B5FcP'><center id='B5FcP'></center></pre></bdo></b><th id='B5FcP'></th></span></q></dt></tr></i><div id='B5FcP'><tfoot id='B5FcP'></tfoot><dl id='B5FcP'><fieldset id='B5FcP'></fieldset></dl></div>

  2. <legend id='B5FcP'><style id='B5FcP'><dir id='B5FcP'><q id='B5FcP'></q></dir></style></legend>

    <small id='B5FcP'></small><noframes id='B5FcP'>

      • <bdo id='B5FcP'></bdo><ul id='B5FcP'></ul>

      一些 UIViewControllers 中的 XAMARIN.IOS UITabBarController

      时间:2023-06-11

        <i id='xye9D'><tr id='xye9D'><dt id='xye9D'><q id='xye9D'><span id='xye9D'><b id='xye9D'><form id='xye9D'><ins id='xye9D'></ins><ul id='xye9D'></ul><sub id='xye9D'></sub></form><legend id='xye9D'></legend><bdo id='xye9D'><pre id='xye9D'><center id='xye9D'></center></pre></bdo></b><th id='xye9D'></th></span></q></dt></tr></i><div id='xye9D'><tfoot id='xye9D'></tfoot><dl id='xye9D'><fieldset id='xye9D'></fieldset></dl></div>
          <tbody id='xye9D'></tbody>

      • <legend id='xye9D'><style id='xye9D'><dir id='xye9D'><q id='xye9D'></q></dir></style></legend>
          • <bdo id='xye9D'></bdo><ul id='xye9D'></ul>

              1. <tfoot id='xye9D'></tfoot>

                <small id='xye9D'></small><noframes id='xye9D'>

                本文介绍了一些 UIViewControllers 中的 XAMARIN.IOS UITabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个应用程序 (Xamarin.IOS),它以没有 TabBar 的 UIViewController(连接视图)开头.但是当用户登录时,我想将我创建的标签栏添加到其他视图中.反之亦然,当用户注销时,我想显示没有 TabBar 的连接视图.

                我知道当我想显示 TabBar 时,在 appDelegate 中,我必须像这样初始化 _window:

                _tabController = new TabController();_window.RootViewController = _tabController;_window.MakeKeyAndVisible();

                如果我想要一个没有 TabBar 的视图,这里是 appDelegate:

                viewController = new ConnectionViewController();_window.RootViewController = new UINavigationController(viewController);_window.MakeKeyAndVisible();

                使用这个 TabController :

                公共类 TabController : UITabBarController{UIViewController tab1, tab2, tab3, tab4;公共标签控制器(){tab1 = new UINavigationController(new ListViewController());tab1.Title = Texts.Home;tab1.TabBarItem.Image = UIImage.FromFile("Icons/Home@2x.png");tab2 = 新 UINavigationController(新 OViewController(1));tab2.Title = Texts.Categories;tab2.TabBarItem.Image = UIImage.FromFile("Icons/Tag@2x.png");tab3 = new UINavigationController(new SearchViewController());tab3.Title = 文本搜索;tab3.TabBarItem.Image = UIImage.FromFile("Icons/Search@2x.png");tab4 = new UINavigationController(new BookmarkViewController(1));tab4.Title = Texts.Bookmarks;tab4.TabBarItem.Image = UIImage.FromFile("Icons/Favorite@2x.png");var 选项卡 = 新 UIViewController[] {选项卡1、选项卡2、选项卡3、选项卡4};this.TabBar.BackgroundColor = UIColor.White;视图控制器 = 选项卡;}}

                但是如何从带有 TabBar 的视图移动到不带 TabBar 的视图,反之亦然?

                我不使用 StoryBoard,而是在 Xamarin.iOS 上编写代码.

                解决方案

                制表符 -> 无制表符

                1. 推送时

                  ViewController2 vc2 = new ViewController2();vc2.HidesBottomBarWhenPushed = true;//添加这一行this.NavigationController.PushViewController(vc2, true);

                2. 在场时

                  this.PresentViewController(new ViewController2(), true, null);

                <块引用>

                无标签 -> 标签

                先将Connection Page设置为RootViewController,然后根据需要修改.

                代码:

                公共部分类 AppDelegate : UIApplicationDelegate{UIWindow 窗口;public override bool FinishedLaunching (UIApplication app, NSDictionary options){窗口 = 新的 UIWindow (UIScreen.MainScreen.Bounds);window.RootViewController = new UINavigationController(new ViewController1());window.MakeKeyAndVisible();返回真;}公共无效changeRootVC(){window.RootViewController = new TabController();}}

                并在Connection Page中更改

                如果(已连接){AppDelegate app = UIApplication.SharedApplication.Delegate as AppDelegate;app.changeRootVC();}

                I have an application (Xamarin.IOS) which start with a UIViewController (Connection view) with no TabBar. But when user Logged, I'd like to add the tabbar that I've created to other views. And vis-versa, when user logged out, I'd like to display the connection view without TabBar.

                I know that when I want to display the TabBar, in appDelegate, I have to initialize _window like this :

                _tabController = new TabController();
                _window.RootViewController = _tabController;
                _window.MakeKeyAndVisible();
                

                and if I want to have a view without TabBar, here is appDelegate:

                viewController = new ConnectionViewController();
                _window.RootViewController = new UINavigationController(viewController);
                _window.MakeKeyAndVisible();
                

                with this TabController :

                public class TabController : UITabBarController
                    {
                
                        UIViewController tab1, tab2, tab3, tab4;
                
                        public TabController()
                        {
                            tab1 = new UINavigationController(new ListViewController());
                            tab1.Title = Texts.Home;
                            tab1.TabBarItem.Image = UIImage.FromFile("Icons/Home@2x.png");
                
                            tab2 = new UINavigationController(new OViewController(1));
                            tab2.Title = Texts.Categories;
                            tab2.TabBarItem.Image = UIImage.FromFile("Icons/Tag@2x.png");
                
                            tab3 = new UINavigationController(new SearchViewController());
                            tab3.Title = Texts.Search;
                            tab3.TabBarItem.Image = UIImage.FromFile("Icons/Search@2x.png");
                
                            tab4 = new UINavigationController(new BookmarkViewController(1));
                            tab4.Title = Texts.Bookmarks;
                            tab4.TabBarItem.Image = UIImage.FromFile("Icons/Favorite@2x.png");
                
                
                            var tabs = new UIViewController[] {
                                tab1, tab2, tab3, tab4
                            };
                
                            this.TabBar.BackgroundColor = UIColor.White;
                
                            ViewControllers = tabs;
                        }
                    }
                

                But how can I move from a view with TabBar to a view without and vis-versa ?

                I don't use StoryBoard and I code on Xamarin.iOS.

                解决方案

                Tab -> No Tab

                1. When Push

                  ViewController2 vc2 = new ViewController2();
                  vc2.HidesBottomBarWhenPushed = true; //add this line
                  this.NavigationController.PushViewController(vc2, true);
                  

                2. When Present

                  this.PresentViewController(new ViewController2(), true, null);
                  

                No Tab -> Tab

                Set Connection Page as RootViewController at first, and then change it when you want to.

                Code:

                public partial class AppDelegate : UIApplicationDelegate
                {
                    UIWindow window;
                
                    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
                    {
                        window = new UIWindow (UIScreen.MainScreen.Bounds);
                
                        window.RootViewController = new UINavigationController(new ViewController1());
                        window.MakeKeyAndVisible();
                        return true;
                    }
                
                    public void changeRootVC()
                    {
                        window.RootViewController = new TabController();
                    }
                }
                

                And change it in Connection Page

                if(connected){
                     AppDelegate app = UIApplication.SharedApplication.Delegate as AppDelegate;
                     app.changeRootVC();
                }
                

                这篇关于一些 UIViewControllers 中的 XAMARIN.IOS UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何同时滑入/滑出状态栏和导航栏? 下一篇:hidesBottomBarWhenPushed 但在弹出时

                相关文章

                <legend id='Ii5qX'><style id='Ii5qX'><dir id='Ii5qX'><q id='Ii5qX'></q></dir></style></legend>

                  <small id='Ii5qX'></small><noframes id='Ii5qX'>

                    <bdo id='Ii5qX'></bdo><ul id='Ii5qX'></ul>
                  <tfoot id='Ii5qX'></tfoot>

                    <i id='Ii5qX'><tr id='Ii5qX'><dt id='Ii5qX'><q id='Ii5qX'><span id='Ii5qX'><b id='Ii5qX'><form id='Ii5qX'><ins id='Ii5qX'></ins><ul id='Ii5qX'></ul><sub id='Ii5qX'></sub></form><legend id='Ii5qX'></legend><bdo id='Ii5qX'><pre id='Ii5qX'><center id='Ii5qX'></center></pre></bdo></b><th id='Ii5qX'></th></span></q></dt></tr></i><div id='Ii5qX'><tfoot id='Ii5qX'></tfoot><dl id='Ii5qX'><fieldset id='Ii5qX'></fieldset></dl></div>