In this recipe, we will learn how to display multiple view controllers in a tabbed interface.
The UITabBarController
class provides a way to display different view controllers on the same hierarchy level divided into a tab-like interface. Create a new iPhone Empty Project in Xamarin Studio and name it TabControllerApp
.
Perform the following steps to provide controllers in tabs:
Add two iPhone view controllers to the project. Name them
MainController
andSettingsController
.Add the following code to the
ViewDidLoad
method ofMainController
:this.View.BackgroundColor = UIColor.Blue;
Add the following code to the
ViewDidLoad
method ofSettingsController
:this.View.BackgroundColor = UIColor.Yellow;
Add the following code to the
FinishedLaunching
method of theAppDelegate
class:MainController mainController = new MainController(); SettingsController settingsController = new SettingsController(); UITabBarController tabController = new UITabBarController...