如何从一个选项卡切换到另一个选项卡Xamarin IOS

时间:2014-08-13 13:45:10

标签: c# ios xamarin uitabbarcontroller tabbar

我创建的UITabBarController类有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;

在第三个控制器中,我有一个提交按钮。

在提交按钮操作时,我想将标签从controller3切换为controller5

我将如何做到这一点?

1 个答案:

答案 0 :(得分:7)

这样的事情:

this.TabBarController.SelectedIndex = 4;