Last listened to The Ricky Gervais Show 2002-02-09 by Ricky Gervais, Stephen Merchant & Karl Pilkington (on 25 Aug 2010, 16:00)

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 |

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 |

5/22/2010 11:27:06 PM #

pingback

Pingback from 456.rkwrh.com

G2500 Minivan, 8.4 V Mini Hard Drive

456.rkwrh.com |

Comments are closed