In this recipe, we will learn how to use the UIViewController
class to manage views.
Add a new file to the project.
Right-click on the project in the Solution pad and select Add | New File….
In the dialog box that will appear, select iPhone View with Controller from the MonoTouch section. Name it
MainViewController,
and click on the New button. MonoDevelop will create a newXIB
file and will automatically open theMainViewController.cs
source file. This file contains a class that overrides theUIViewController
, and we can implement any code related to our view controller in it.Open the
MainViewController.xib
file in Interface Builder.Add a
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 label.Save the
XIB
document.Back in MonoDevelop, enter...