In this recipe, we will learn how to use the UIViewController
class to manage views.
Perform the following steps to load a view with a view controller:
Add a new file to the project.
Right-click on the project in the Solution pad and go to Add | New File….
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 theMainViewController.cs
source file. This file contains a class that overrides theUIViewController
class, and we can implement any code related to our view controller in it.Open the
MainViewController.xib
file in Interface Builder.Add
UILabel
on the view.Create and connect an outlet for it inside the
MainViewController
class and name itmyLabel
.Enter the text
View in controller!
in the...