Ben Krueger
Ben Krueger

Reputation: 1536

Deleting a section from a UITableView. NSIndexSet parameter?

I am trying to delete a section in a table after I have verified it has no more rows, but I am not sure what I am supposed to pass to it for the NSIndexSet parameter. Here is a code snippet I am using it in:

        public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
    {
        if (editingStyle == UITableViewCellEditingStyle.Delete) {
            BreakawayDB.UpdateUserTeam (_indexedTableItems[_keys[indexPath.Section]][indexPath.Row].TeamID, false);
            _indexedTableItems[_keys[indexPath.Section]].RemoveAt (indexPath.Row);

            tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);

            if(_indexedTableItems[_keys[indexPath.Section]].Count == 0){
                tableView.DeleteSections( new NSIndexSet[] { ????? }, UITableViewRowAnimation.Fade);
            }
        }
    }

Any tips?

Upvotes: 0

Views: 708

Answers (1)

Jason
Jason

Reputation: 89102

try this:

tableView.DeleteSections( NSIndexSet.FromIndex (indexPath.Section), UITableViewRowAnimation.Fade);

Upvotes: 2

Related Questions