I'm getting a little lost trying to use both a UITabBarController and UINavigationController in MonoTouch.
I can create a navigation based project, and navigate using only a navigationController, fine. Or I can add a tabBarController and navigating to a couple of main screens, fine.
However, I can't seem to navigate to another without using the TabBarController if one is present. E.g, I'm doing an app that deals with "foo", so I am two views on my tabbar, FooHome, and FooSettings. How do I navigate to a new view if the user click something like "Add Foo" on the FooSettings view.
The NavigationController.PushToView doesn't seem to have any effect, and I don't want to add the view to the tabController since its nice and simple with only two items.
Should I be using this.View.AddSubView? The idea sort of sounds like a dialog box, I'm just not sure how to do it with monoTouch...
I was wrestling with this for hours and this post helped. Thank you so much. For those still in the dark a little, here's my code:
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
var vc1 = new VideosVC ();
var vc2 = new ScheduleVC ();
var vc3 = new TheCastVC ();
var vc4 = new MerchandiseVC ();
UINavigationController uinc1 = new UINavigationController(vc1);
UINavigationController uinc2 = new UINavigationController(vc2);
UINavigationController uinc3 = new UINavigationController(vc3);
UINavigationController uinc4 = new UINavigationController(vc4);
tabBarController = new UITabBarController ();
tabBarController.ViewControllers = new UIViewController [] {
uinc1,
uinc2,
uinc3,
uinc4,
};
window.RootViewController = tabBarController;
window.MakeKeyAndVisible ();
return true;
}
Add your FooHome and FooSettings controllers to UINavigationControllers and set those navigation controllers to your tab controller.
So for example, the first tab will contain a navigation controller whose root controller is FooHome and the second tab will contain a navigation controller whose root controller is FooSettings.
When you tap on Add Foo in FooSettings, you will push the new controller inside the second tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With