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

Loading a view with a view controller


In this recipe, we will learn how to use the UIViewController class to manage views.

Getting ready

Create a new iPhone Empty Project in Xamarin Studio and name it ViewControllerApp.

How to do it...

Perform the following steps to load a view with a view controller:

  1. Add a new file to the project.

  2. Right-click on the project in the Solution pad and go to Add | New File….

  3. In the dialog that will appear, select iPhone View Controller from the iOS section. Name it MainViewController and click on the New button. Xamarin Studio will create a new XIB file and will automatically open the MainViewController.cs source file. This file contains a class that overrides the UIViewController class, and we can implement any code related to our view controller in it.

  4. Open the MainViewController.xib file in Interface Builder.

  5. Add UILabel on the view.

  6. Create and connect an outlet for it inside the MainViewController class and name it myLabel.

  7. Enter the text View in controller! in the...