Book Image

iOS Development using MonoTouch Cookbook

By : Dimitris Tavlikos
Book Image

iOS Development using MonoTouch Cookbook

By: Dimitris Tavlikos

Overview of this book

<p>MonoTouch brings the amazing revenue opportunities of Apple’s billion dollar app store to C# and .NET developers. <br /><br />This cookbook leaves no stone unturned, providing you with practical recipes covering user interfaces, data management, multimedia , web services, and localization, right through to application deployment on the app store.<br /><br />Whatever the area of MonoTouch iOS development you need to know about, you will find a recipe for it in this cookbook. Minimum theory and maximum practical action defines this book. It is jam packed with recipes for interacting with the device hardware, like the GPS, compass and the accelerometer. Recipes for those all important real world issues such as designing the UI with the integrated designer introduced with Xcode 4. It is the essential cookbook for C# and .NET developers wanting to be part of the exciting and lucrative world of iOS development.</p>
Table of Contents (22 chapters)
iOS Development Using MonoTouch 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 contained in an XIB file.

Getting ready

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 .

How to do it...

  1. Add a new empty C# class in the project, and name it BaseController.

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