Last listened to Symphony No. 4 in G (1993 Digital Remaster): III. Ruhevoll by Paul Kletzki (on 6 Sep 2010, 05:25)

This post has been removed by the author.

Check out this similar post by Paulio: Creating a very simple MonoTouch application without the Interface Builder.



Selecting a contact from the Address Book with MonoTouch

This screencast shows how to programmatically select a contact from the address book in a MonoTouch iPhone application, in only 5 minutes.

The key bit of code is to create an ABPeoplePickerNavigationController, and then take advantage of its SelectPerson event. The brief idea is shown in this code snippet:

var picker = new ABPeoplePickerNavigationController();

picker.SelectPerson +=
delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
ABPerson selectedPerson = e.Person;
// do something with 'selectedPerson'
};

Hope you found this screencast helpful.

Deleting cells from a UITableView with MonoTouch

This screencast shows the end-to-end process of how to create a simple iPhone application with MonoTouch. The application displays data in a table, and gives the user the ability to delete cells from the table.

The application consists of a UINavigationController, a UITableViewController and of course some UITableViewCells which can be deleted from their containing table.

Some things I mention in the screencast are:

  • Just like in my UINavigationController RSS example, I am using a template for UITableViewControllers which is based on the one I found at Code Snack.
  • Swipe to delete is enabled simply by overriding the CommitEditingStyle method in your UITableViewDataSource class.

The key bit of code from this example is the CommitEditingStyle method:

class DataSource : UITableViewDataSource
{
EmployeesTableViewController tvc;

// ...

public override void CommitEditingStyle(UITableView tableView,
UITableViewCellEditingStyle editingStyle,
NSIndexPath indexPath)
{
if (editingStyle == UITableViewCellEditingStyle.Delete)
{
tvc.Employees.RemoveAt(indexPath.Row);
tableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Fade);
}
}
// ...

MonoTouch code snippet - Application Icon Badge Number

Another MonoTouch code snippet: how to set the "new items" number on your iPhone apps badge:

UIApplication.SharedApplication.ApplicationIconBadgeNumber = 11;

That will give you this result:

MonoTouch code snippet - Network Activity Indicator

The network activity indicator is in the status bar at the very top of the screen on an iPhone. You can see it just to the left of the time in this screenshot:

Network Activity Indicator in an iPhone app

In Objective-C, you can control when this is shown or not by this code:

// Show
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
// Hide
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

With MonoTouch and C# the code is almost identical:

// Show
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

// Hide
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;