Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UITableViewCell中的UITableView缺少事件_C#_Ios_Uitableview_Xamarin.ios_Tableviewcell - Fatal编程技术网

C# UITableViewCell中的UITableView缺少事件

C# UITableViewCell中的UITableView缺少事件,c#,ios,uitableview,xamarin.ios,tableviewcell,C#,Ios,Uitableview,Xamarin.ios,Tableviewcell,我实现了一个UITableView,其中包含一个自定义的UITableViewCell,其中包含一个UITableView,我能够正确绑定所有数据,但我缺少的是内部UITableView中没有触发的事件 基本上: 等等 内部UITableView内的滑动手势未触发,实际上未触发任何事件。我尝试过覆盖触摸事件,但没有命中。我尝试了很多没有用的事情,包括打电话给NextResponder touch events 包含外部UITableView的视图是可滚动的,可能与此有关 我想要实现的是,只有第2

我实现了一个UITableView,其中包含一个自定义的UITableViewCell,其中包含一个UITableView,我能够正确绑定所有数据,但我缺少的是内部UITableView中没有触发的事件

基本上:

等等

内部UITableView内的滑动手势未触发,实际上未触发任何事件。我尝试过覆盖触摸事件,但没有命中。我尝试了很多没有用的事情,包括打电话给NextResponder touch events

包含外部UITableView的视图是可滚动的,可能与此有关

我想要实现的是,只有第2行被扫描,而不是整个内部UITableView。当从外部UITableView执行时,它可以工作,但这不是要求,因为第1行和第2行都被扫描,但是由于事件没有传递下来,我无法使它工作

我错过了什么

以下是我在外部UITableView自定义单元格内定义内部UITableView的方式:

public PlanningGwWrapperCell(IntPtr handle) : base(handle)
{
    _playersTable = new PlanningPlayersTableView();
    _playersTableSource = new MvxPlanningGwPlayersTableViewSource(_playersTable);

    _layout = CreateLayout();

    _playersTable.Source = _playersTableSource;
    _playersTable.Delegate = new PlanningGwPlayersTableDelegate();

    ContentView.AddSubview(new UILayoutHost(_layout));

    InitializeBindings();

    _playersTable.ReloadData();
}
_布局是一种线性布局

UITableView就是这样的:

class PlanningPlayersTableView : UITableView
{
    public PlanningPlayersTableView()
    {
        PrepareTable();
    }

    void PrepareTable()
    {
        SeparatorStyle = UITableViewCellSeparatorStyle.None;
        RowHeight = Dimens.TableRowHeight;
        ScrollEnabled = false;
        BackgroundColor = Colors.AppBackground;
    }
}
表格来源为:

public class MvxPlanningGwPlayersTableViewSource : BaseMvxTableViewSource<PlanningGwPlayersCell>
{
    public MvxPlanningGwPlayersTableViewSource(UITableView tableView)
        : base(tableView)
    {
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return 1;
    }

    public override nint NumberOfSections(UITableView tableView)
    {
        return 1;
    }

    public override bool CanEditRow(UITableView tableView, NSIndexPath indexPath)
    {
        var source = (MvxPlanningGwPlayersTableViewSource)tableView.Source;
        var itemsSource = (source).ItemsSource;

        if (itemsSource == null) return false;

        var row = ((ObservableCollection<PlanningGWItemsViewModel>)itemsSource)[indexPath.Row];

        return row.CanAdd || row.CanRemove;
    }

    public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
    {
        switch (editingStyle)
        {
            case UITableViewCellEditingStyle.None:
                break;
        }
    }

    public override UITableViewCellEditingStyle EditingStyleForRow(UITableView tableView, NSIndexPath indexPath)
    {
        return UITableViewCellEditingStyle.Delete;
    }

    protected override UITableViewCell GetOrCreateCellFor(UITableView tableView, NSIndexPath indexPath, object item)
    {
        return (PlanningGwPlayersCell)tableView.DequeueReusableCell(PlanningGwPlayersCell.Id);
    }
}

UILayoutHost正在吞并事件,如果我将表作为子视图直接放在其中,则会保留事件。

答案确实是将标题行第一行拆分,并从UILayoutHost中滑动第二行:

public PlanningGwWrapperCell(IntPtr handle)
        : base(handle)
    {
        ...

        ContentView.AddSubview(new UILayoutHost(_header));
        ContentView.AddSubview(_playersTable);

        InitializeBindings();

        _playersTable.ReloadData();
    }

    public override void LayoutSubviews()
    {
        base.LayoutSubviews();

        _playersTable.Frame = new CGRect(0, Dimens.TableRowHeight, ContentView.Bounds.Width, Dimens.TableRowHeight);
        _header.LayoutParameters = new LayoutParameters(ContentView.Bounds.Width, Dimens.TableRowHeight);
    }
ContentView.AddSubview(new UILayoutHost(_layout));
public PlanningGwWrapperCell(IntPtr handle)
        : base(handle)
    {
        ...

        ContentView.AddSubview(new UILayoutHost(_header));
        ContentView.AddSubview(_playersTable);

        InitializeBindings();

        _playersTable.ReloadData();
    }

    public override void LayoutSubviews()
    {
        base.LayoutSubviews();

        _playersTable.Frame = new CGRect(0, Dimens.TableRowHeight, ContentView.Bounds.Width, Dimens.TableRowHeight);
        _header.LayoutParameters = new LayoutParameters(ContentView.Bounds.Width, Dimens.TableRowHeight);
    }