简体   繁体   中英

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?

尝试这个:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM