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

Loading a view with a view controller


In this recipe, we will learn how to use the UIViewController class to manage views.

Getting ready

Create a new iPhone empty project in MonoDevelop, and name it ViewControllerApp .

How to do it...

  1. Add a new file to the project.

  2. Right-click on the project in the Solution pad and select Add | New File….

  3. 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 new XIB file and will automatically open the MainViewController.cs source file. This file contains a class that overrides the UIViewController, and we can implement any code related to our view controller in it.

  4. Open the MainViewController.xib file in Interface Builder.

  5. Add a UILabel on the view.

  6. Create and connect an outlet for it inside the MainViewController class, and name it myLabel.

  7. Enter the text View in controller! in the label.

  8. Save the XIB document.

  9. Back in MonoDevelop, enter...