kiran
kiran

Reputation: 4409

how to switch from one tab to another tab Xamarin IOS

I created UITabBarController class to have 5 ViewControllers

        controller1 = new Controller1();
        controller2 = new Controller2();
        controller3 = new Controller3();
        controller4 = new Controller4();
        controller5 = new Controller5();

        controller1.TabBarItem = new UITabBarItem ("first", UIImage.FromFile("/Images/first.png"), 0);
        controller5.TabBarItem = new UITabBarItem ("second", UIImage.FromFile("/Images/four.png"), 1);
        controller5.TabBarItem = new UITabBarItem ("third", UIImage.FromFile("/Images/four.png"), 2);
        controller5.TabBarItem = new UITabBarItem ("four", UIImage.FromFile("/Images/four.png"), 3);
        controller5.TabBarItem = new UITabBarItem ("five", UIImage.FromFile("/Images/four.png"), 4);

    var tabs = new UIViewController[] {
            controller1, controller2, controller3, controller4, controller5 
        };
        ViewControllers = tabs;

In the third controller I have a submit button.

On submit button action, I would like to switch tab from controller3 to controller5.

How would I go about doing this?

Upvotes: 2

Views: 3590

Answers (1)

Chris
Chris

Reputation: 3338

Something like this:

this.TabBarController.SelectedIndex = 4;

Upvotes: 8

Related Questions