Last listened to The Getaway by Immortal Technique (on 10 Mar 2010, 14:39)

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);
        }
    }
    // ...

Comments

10/29/2009 9:54:02 PM #

trackback

MonoTouch Video - Deleting cells from a UITableView with MonoTouch

Thank you for submitting this entry - Trackback from MonoTouch.Info

MonoTouch.Info | Reply

10/29/2009 10:35:06 PM #

pingback

Pingback from topsy.com

Twitter Trackbacks for
        
        Alex York .NET | Deleting cells from a UITableView with MonoTouch
        [alexyork.net]
        on Topsy.com

topsy.com | Reply

10/30/2009 9:51:06 PM #

trackback

Social comments and analytics for this post

This post was mentioned on Twitter by alex_york: Blogged: Deleting cells from a UITableView with MonoTouch (Screencast) http://bit.ly/4FtNlB

uberVU - social comments | Reply

Add comment




  Country flag

Visual verification


biuquote
  • Comment
  • Preview
Loading