Reputation: 45
Forgive me for my ignorance, as I'm new to Monotouch and I'm sure this is a simple thing but I can't find the answer anywhere.
I have an iPhone app in Monotouch that uses a UITabBarController for root navigation. It is defined in it's own class file. There is also a separate view controller class file for the content of each tab. So tab1 shows viewcontroller1, tab2 shows viewcontroller2, etc.
I want a user to be able to click on button1 inside of viewcontroller1 and have the app take them to tab2 and show viewcontroller2.
I have an event handled for the click of button1 and I can do things like pop up alerts when it's clicked, but I can't figure out how to get the tab bar to be accessible for me to call it. Please help!
Edit: I need to know not only how to make it accessible, but I also don't know what method to call to make it change.
Upvotes: 3
Views: 1422
Reputation: 273
something like
btn1.TouchUpInside += (sender, args) => TabBarController.SelectedIndex = 0 ;
Upvotes: 1
Reputation: 89092
When you create your "child" view controllers, pass in a reference to the "parent" tab controller. Then you child can call a method on it's parent to update the current tab index.
Upvotes: 1