XAMARIN.IOS UITabBarController in some UIViewControllers

前端 未结 1 1216
无人共我
无人共我 2021-01-03 08:54

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 create

相关标签:
1条回答
  • 2021-01-03 09:38

    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();
    }
    

    0 讨论(0)
提交回复
热议问题