In this recipe, we will learn how to create a subclass of UIViewController
and use it to derive view controllers that were created in Interface Builder.
In this recipe, we will create a custom view controller that will act as a base controller, providing common functionality among its inheritors. Create a new iPhone Empty Project in Xamarin Studio and name it CustomControllerApp
.
Perform the following steps:
Right-click on the project in the Solution pad and go to Add | New File….
In the dialog that appears, navigate to General | Empty Class. Name the file
BaseController
and click on the New button.Open the
BaseController.cs
file that was just created and modify it to match the following code:using System; using MonoTouch.UIKit; using MonoTouch.Foundation; using System.Drawing; namespace CustomControllerApp { public class BaseController : UIViewController { //Constructor public BaseController (string nibName, NSBundle bundle...