Sierra
Sierra

Reputation: 337

uitabbarcontroller not working properly in xamarin iOS mono touch

i have created uitabbarcontroller which is not properly working,my issue is if i click second tab bar the corresponding view is not visible only the first view is visible for all actions.i couldn't navigate and see the next views.

my code is :

  if (this.tabBarController == null) 


      { 
   

    this.tabBarController = new UITabBarController ();

    

        }  

      var viewController1=new Filterview();
  

      var viewController2=new SearchView();

      tabBarController = new UITabBarController ();
    

  tabBarController.ViewControllers = new UIViewController []

         {

                    

           viewController1,


        viewController2,

  

          } ;



     viewController2.TabBarItem = new UITabBarItem (UITabBarSystemItem.Search, 1);



     viewController1.TabBarItem = new UITabBarItem ("Filter", UIImage.FromFile ("Images/1382614124_filter.png"), 0);

      this.NavigationController.PushViewController (this.tabBarController, true);

this code is not working pl anybody suggest me how to create uitabbar in iOS xamarin mono touch applications.

Upvotes: 1

Views: 747

Answers (1)

Krumelur
Krumelur

Reputation: 33048

UITabBarController is a root controller. This means it is supposed as the topmost controller in your hierarchy. You are pushing this controller on a UINavigationController. This is most probably causing the issues you see. Try to set your tab bar controller in your app delegate:

window.RootViewController = someTabBarController;

Let me quote from Apple's documentation:

When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

Upvotes: 3

Related Questions