Xamarion ios side menu drawer with a tab bar controller

NaffieMNaffieM USUniversity ✭✭
edited November 2015 in Xamarin.iOS

Hi guys, I've been trying to implement Dillon Buchanan's SlideoutNavigation example from this link https://github.com/thedillonb/MonoTouch.SlideoutNavigation . In his example, he has a SlideoutNavigationController class which is the root view controller and encapsulates a home view controller and a menu class.

The challenge I have is that my home view controller is a tab bar controller class and each tab has it's own navigation controller. The tab bar controller also has to be the root view controller and shouldn't be wrapped around another navigation controller.

So currently I have 2 challenges:

The navigation controllers of my tabs views are obscured by the main navigation controller set by the root view. I can't see the titles of each tab
Any subsequent views I instantiate from the tabs also lose the back button. It's not displayed.
Any reference to the NavigationController from within the tabs or the MainTabBarController class always returns null.

Here's the code:

AppDelegate class where I set the root view controller

[Register ("AppDelegate")]
 public class AppDelegate : UIApplicationDelegate
 {
    public SlideoutNavigationController Menu { get; private set; }

  public override bool FinishedLaunching (UIApplication application,     NSDictionary launchOptions)
     {
                 Menu = new SlideoutNavigationController ();

  var tabBarController = GetViewController (Main, "MainTabBarController");

            Menu.MainViewController = new MainNavigationController (tabBarController, Menu);
            Menu.MenuViewController = new MenuNavigationController (new MenuControllerLeft (), Menu) { NavigationBarHidden = true };
            SetRootViewController (Menu, false);

    return true;
}

**The MainTabController class
**

public partial class MainTabBarController : UITabBarController
 {
        UINavigationItem titleRequest,titleHome,titleSell;

   public MainTabBarController (IntPtr handle) : base (handle)
     {
   //Create an instance of our AppDelegate
         appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;

    //Get an instance of our Main.Storyboard
    var mainStoryboard = appDelegate.Main;

    var tab1 = appDelegate.GetViewController (mainStoryboard, "Tab1");

    var tab2 = appDelegate.GetViewController (mainStoryboard, "Tab2");

    var tab3 = appDelegate.GetViewController (mainStoryboard, "Tab3");


    var tabs = new UIViewController[] {
        tab1, tab2, tab3
    };

         this.SelectedIndex = 1;
         ViewControllers = tabs;
   }

   public override void ViewDidLoad ()
     {
    base.ViewDidLoad ();


        if(this.SelectedIndex == 0)
        {

            titleRequest = new UINavigationItem ("TAB 1");
            this.NavigationController.NavigationBar.PushNavigationItem (titleRequest, true); // NavigationController here is null

        }else if(this.SelectedIndex == 1)
        {
            titleHome = new UINavigationItem ("TAB 2");
            this.NavigationController.NavigationBar.PushNavigationItem (titleHome, true);


        }else{

            titleSell = new UINavigationItem ("TAB 3");
            this.NavigationController.NavigationBar.PushNavigationItem (titleSell, true);
        }

   }
 }

So I have two questions:

1.Is there a way to work around the tab bar controller not being the root view?
2.Could someone point me to any other implementation of a simpler model of a slide out navigation drawer in Xamarin iOS which includes a tab bar controller?

Best Answer

Answers

  • Alan321Alan321 USMember

    I'm trying to do the exact same thing: My primary navigation is a drawer-style list that pulls out from the left upon clicking a hamburger menu icon. One section requires subnavigation which I want to present to the user as 4 tabs at the bottom. This section's content is basically an app within an app. Please let me know if you find a solution.

  • SagarPanwalaSagarPanwala USMember ✭✭✭

    Hello Guys,
    Can you please provide any sample , I need to implement right drawer also.

Sign In or Register to comment.