Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Providing controllers in tabs


In this recipe, we will learn how to display multiple view controllers in a tabbed interface.

Getting ready

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.

How to do it…

Perform the following steps to provide controllers in tabs:

  1. Add two iPhone view controllers to the project. Name them MainController and SettingsController.

  2. Add the following code to the ViewDidLoad method of MainController:

    this.View.BackgroundColor = UIColor.Blue;
  3. Add the following code to the ViewDidLoad method of SettingsController:

    this.View.BackgroundColor = UIColor.Yellow;
  4. Add the following code to the FinishedLaunching method of the AppDelegate class:

    MainController mainController = new MainController();
    SettingsController settingsController = new SettingsController();
    UITabBarController tabController = new UITabBarController...