Xamarin uitableviewcell附件类型未显示在首次单击中

Xamarin uitableviewcell附件类型未显示在首次单击中,xamarin,xamarin.ios,Xamarin,Xamarin.ios,我有自定义UITableViewCell和此代码,用于在单击行时创建附件 public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (this.checkedIndexPath != null) { var uncheckCell = tableView.CellAt(checkedIndexPath) as UITabl

我有自定义UITableViewCell和此代码,用于在单击行时创建附件

 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
    {
        if (this.checkedIndexPath != null)
        {
            var uncheckCell = tableView.CellAt(checkedIndexPath) as UITableViewCell;
            if (uncheckCell != null)
            { 
                uncheckCell.Accessory = UITableViewCellAccessory.None;
            }
        }
        if (tableView.CellAt(indexPath) is UITableViewCell cell)
        {
            cell.Accessory = UITableViewCellAccessory.Checkmark; 
        }
        this.checkedIndexPath = indexPath;
    }

我有个问题。当我第一次单击单元格时。附件类型不变。当我单击另一个单元格时,附件类型会更改。但第二次鼠标单击的附件类型在我单击表中的另一个单元格之前不会更改

要使更改生效,您需要重新加载当前单元格

tableView.ReloadRows(indexPath, UITableViewRowAnimation.None);
将其添加到代码末尾

 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
    {
        if (this.checkedIndexPath != null)
        {
            var uncheckCell = tableView.CellAt(checkedIndexPath) as UITableViewCell;
            if (uncheckCell != null)
            { 
                uncheckCell.Accessory = UITableViewCellAccessory.None;
            }
        }
        if (tableView.CellAt(indexPath) is UITableViewCell cell)
        {
            cell.Accessory = UITableViewCellAccessory.Checkmark; 
        }
        this.checkedIndexPath = indexPath;

        //Reload current cell
        tableView.ReloadRows(indexPath, UITableViewRowAnimation.None);
    }