In this recipe, we will learn how to create a subclass of UIViewController
and use it to derive view controllers contained in an XIB
file.
In this task, we will see how to create a custom view controller that will act as a base controller, providing common functionality among its inheritors. The functionality we will add to our base controller to share with its inheritor classes will be to output the current touch position in the Application Output pad in MonoDevelop. Create a new iPhone empty project in MonoDevelop, and name it CustomControllerApp
.
Add a new empty C# class in the project, and name it BaseController.
Enter the following code in the BaseController.cs file:
using System; using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; public class BaseController : UIViewController{ //Constructors public BaseController (string nibName, NSBundle bundle) : base(nibName, bundle){} public override void TouchesMoved...