Xamarin.ios tableview滚动上的MonoTouch NullReferenceException

Xamarin.ios tableview滚动上的MonoTouch NullReferenceException,xamarin.ios,nullreferenceexception,Xamarin.ios,Nullreferenceexception,在我的应用程序中,我只是尝试向所选行添加复选标记。我的行中有大约20个项目,希望显示选中行的复选标记。当我滚动到页面底部并选择一行时,它会抛出NullReferenceException。我有来自 当我调试时,我发现了那个附件 tableView.CellAt(_previousRow).Accessory Unknown member: Accessory 知道哪里出了问题吗 得到答案了吗 // Row Select public override void RowSe

在我的应用程序中,我只是尝试向所选行添加复选标记。我的行中有大约20个项目,希望显示选中行的复选标记。当我滚动到页面底部并选择一行时,它会抛出NullReferenceException。我有来自

当我调试时,我发现了那个附件

tableView.CellAt(_previousRow).Accessory    Unknown member: Accessory
知道哪里出了问题吗

得到答案了吗

// Row Select
        public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            // Uncheck the previous row
            if (_previousRow != null)
                       {
                               NSIndexPath [] temp = tableView.IndexPathsForVisibleRows;

               if (temp.Contains(preIndex))
               {

                 tableView.CellAt(_previousRow).Accessory = UITableViewCellAccessory.None;
                                }
                         }

            // Do something with the row
            var row = indexPath.Row;
            Settings.SelectedIndex = row;
            tableView.CellAt(indexPath).Accessory = UITableViewCellAccessory.Checkmark;

            //Console.WriteLine("{0} selected",_controller.Items[row]);

            _previousRow = indexPath;

            // This is what the Settings does under Settings>Mail>Show on an iPhone
            tableView.DeselectRow(indexPath,false);

        }

抛出错误时_previousRow的.Row值是多少?它是在您第一次还是第二次选择某个内容时发生的?只有在我滚动然后选择时才会发生。\u上一行的值正确。它显示未知成员:附件所以这是您第二次选择某个内容?我想知道对应的单元格。行值在屏幕上是否可见。是的,这是我第二次选择。例如,我第一次从列表中选择某个内容,然后滚动到列表底部并选择其他内容。它在我设置UITableViewCellAccessory时崩溃。无;对于以前选定的行。如果那一排看不见了,我想它是在扔破例。我得到了解决办法!!!以前选择的行不可见,因此当我使用它设置属性时,它崩溃了。我通过检查它是否可见,然后仅编辑来修复。工作。。。。
tableView.CellAt(_previousRow).Accessory    Unknown member: Accessory
// Row Select
        public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            // Uncheck the previous row
            if (_previousRow != null)
                       {
                               NSIndexPath [] temp = tableView.IndexPathsForVisibleRows;

               if (temp.Contains(preIndex))
               {

                 tableView.CellAt(_previousRow).Accessory = UITableViewCellAccessory.None;
                                }
                         }

            // Do something with the row
            var row = indexPath.Row;
            Settings.SelectedIndex = row;
            tableView.CellAt(indexPath).Accessory = UITableViewCellAccessory.Checkmark;

            //Console.WriteLine("{0} selected",_controller.Items[row]);

            _previousRow = indexPath;

            // This is what the Settings does under Settings>Mail>Show on an iPhone
            tableView.DeselectRow(indexPath,false);

        }