Reputation: 55
I have a Monotouch App, on AppDelegate the RootViewController is a TabBarController, this TabBarController have 5 ViewControllers, lets say view1 to view5, I use
tabBarController.SelectedIndex = 2;
for select which viewController will load when the app starts it works and the default tabBar is view3, now I need to show another viewController, lets say from view1 change to view5 with code, its possible? there's a way to emulate the clic on one of the buttons of my TabBar, that will work too...
UPDATE:
I tried:
view1.TabBarController.ViewControllers[4].PresentViewController(view5, true, delegate{});
And it works, but the view5 is presented over the TabBar, also I try this:
view1.TabBarController.TabBar.Items[4]. //I don't know which method could invoke the click
Where I select the item of the tabbar I want to click
I think the solution is close to this, the problem is that always the view5 shows over the TabBar and block it...
SOLVED:
view1.TabBarController.SelectedIndex = 2; //where the number is the view zero-based
Upvotes: 1
Views: 1204
Reputation: 11945
This what you want? You can call this from any click handler.
AppDelegate.Current.NavController.PushViewController(new View5(), true);
In my AppDelegate class I have:
public partial class AppDelegate : UIApplicationDelegate
{
public static AppDelegate Current { get; private set; }
public UINavigationController NavController { get; private set; }
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
Current = this;
NavController = new UINavigationController();
...
}
}
or do you want to just switch tabs: How to programmatically change views in TabBarViewController?
Upvotes: 1