TechBubbles Microsoft Technology BLOG

iOS Application Development with Xamarin and Visual Studio

As Xamarin allows us to build iOS, Android and windows applications, this post outlines the steps that required developing an iOS application using Xamarin and Visual Studio. What is Xamarin? Build and execution model is different from iOS and Android. In iOS you have something called “Ahead of Time”(AOT) compiling which is basically there to compile your application down to native code. Apple basically says you have to have your binary code on AppStore and it should build on Mac machine. This is exactly what Xamarin does for you.

It is good to know the iOS runtime model before writing the code for it. The iOS runtime essentially looks as shown in the following picture

clip_image002

You have iOS which is a platform and your APP native code; within their you have mono runtime .net base class libraries. Xamarin does some really interesting things like they compile your application and remove anything that is not used properties and methods to keep the file size small.

iOS Application Lifecycle & Structure

You have an application in iOS in foreground with two states as active or inactive states. When your application goes to background it is in backgrounded state. When it is not running state then it is obviously in Not Running state.

clip_image004

When user comes in and uses your App and it will be started up and in Active State, it could be in inactive state for example if phone call comes in or person hits the home button, it could be backgrounded at that point of the time. From the backgrounded state, it could go to active or inactive states. Xamarin notifies us all these states using various overrides in AppDelegates.cs file.

The methods in the delegate for overriding are as follows

clip_image005

iOS Application uses MVC pattern

clip_image007

User performs an action into the controller it then changes the model and updates the UI. You also have states in view controller (UIViewController) level.

clip_image009

During the view development you can use UITableView control which is essential a list view control can be used to show the list of data. You have the data and it is associated with UITableViewSource and you also going to have cells to present the data.

clip_image011

Loading the data in tableview

clip_image013

To bind the returned data to the UI, open the storyboard file from the solution and then drag table view and table view cell controls.

clip_image015

Enable document outline to see what is placed in story board. Set the identifiers to both Table View and Table View Cell.

image

You can bind the loaded data to tableview control as shown in the following picture

clip_image002[1]

In HeritagePropertiesTableViewSource class, you have the logic to iterate and bind the data to cells

clip_image004[1]

When you run the application then you see the data something like in the following screenshot

clip_image006

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

Add Comment

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud