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

Creating a custom view controller


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.

Getting ready

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.

How to do it...

Perform the following steps:

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

  2. In the dialog that appears, navigate to General | Empty Class. Name the file BaseController and click on the New button.

  3. 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...