Xamarin.ios iOS 7:例外情况“;layoutCell/无法识别的选择器“;当点击;“更多”;TabBar按钮

Xamarin.ios iOS 7:例外情况“;layoutCell/无法识别的选择器“;当点击;“更多”;TabBar按钮,xamarin.ios,xamarin,Xamarin.ios,Xamarin,我使用的是UITAbBarViewController,我想自定义“更多”视图,因此我使用了以下代码: `if (this.MoreNavigationController != null) { UITableView tableView = (UITableView)this.MoreNavigationController.TopViewController.View; tableView.BackgroundView = null; tableView.Table

我使用的是UITAbBarViewController,我想自定义“更多”视图,因此我使用了以下代码:

`if (this.MoreNavigationController != null) 
{
    UITableView tableView = (UITableView)this.MoreNavigationController.TopViewController.View;
    tableView.BackgroundView = null;
    tableView.TableFooterView = new UIView (new CGRect ());

    var ds = new MoreTableDataSource (viewControllers.Skip(4).ToArray());

    tableView.Source = ds;
}`
我的类MoreTableDataSource是:

`public class MoreTableDataSource : UITableViewSource
{
        UIViewController[] tableItems;
        protected string cellIdentifier = "TableCell";

        public Action<UIViewController, int> SelectRow { get; set; }

        public MoreTableDataSource (UIViewController[] items)
        {
            this.tableItems = items;

            SelectRow = null;
        }

        public override nint RowsInSection (UITableView tableview, nint section)
        {
            return tableItems.Length;
        }

        public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell (cellIdentifier);
            if (cell == null)
            {
                cell = new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier);
                cell.TextLabel.Text = tableItems[indexPath.Row].Title;
                cell.ImageView.Image = tableItems [indexPath.Row].TabBarItem.Image;
                cell.AccessoryView = ColoredDisclosureIndicator.AccessoryWithColor(TouchApplication.SodexoColor);
            }

            return cell;
        }
    }`
`public类MoreTableDataSource:UITableViewSource
{
UIViewController[]表项;
受保护的字符串cellIdentifier=“TableCell”;
公共操作SelectRow{get;set;}
公共MoreTableDataSource(UIViewController[]项)
{
this.tableItems=项目;
SelectRow=null;
}
公共覆盖第九行第九节(UITableView表格视图,第九节)
{
返回表格项目。长度;
}
公共覆盖UITableViewCell GetCell(UITableView tableView,NSIndexPath indexPath)
{
var cell=tableView.DequeueReusableCell(cellIdentifier);
if(单元格==null)
{
单元格=新的UITableViewCell(UITableViewCellStyle.Default,cellIdentifier);
cell.textlab.Text=tableItems[indexath.Row].Title;
cell.ImageView.Image=tableItems[indexath.Row].TabBarItem.Image;
cell.AccessoryView=ColoredDisclosureIndicator.AccessoryWithColor(TouchApplication.SodexoColor);
}
返回单元;
}
}`
此代码在iOS 8上运行良好,但在iOS 7上引发以下异常:

Foundation.MonoTouchException:引发Objective-C异常。姓名: NSInvalidArgumentException原因:-[MyApp\u Views\u MoreTableDataSource _layoutCells]:发送到实例0x7bf09fa0的无法识别的选择器

我试着在谷歌上搜索,但我找到了任何可以帮助我的东西

有没有人能想出一个主意


谢谢

它可能发生在代码的另一个地方,但仅凭这段代码很难判断。米格尔,谢谢你的回答。当我设置TableView的源(使用TableView.source=ds;)时,问题就出现了。如果我删除这一行,应用程序运行良好(在iOS 7上不再出现崩溃)。这看起来像是与此相同的错误:我通过添加/使用自定义UITableView来管理“更多”表,但我很想知道为什么会发生这种情况:)谢谢!