ChildViewController/View 在 GMSMapView 上无法获得焦点



上下文:我想实现类似的东西 如何模仿地图应用中的底部工作表? 基于 https://github.com/grendio/XBottomSheet/tree/master/XBottomSheet.Samples/XBottomSheet.Touch

问题:如果我将BottomSheet与iOS版Google地图一起使用,它不允许我向上或向下拖动BottomSheet,即使它添加了(它在屏幕上可见)。

代码:如前所述,我有一个谷歌地图视图和我的底表视图:

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        SetMap();
        SetBottomSheet();
    }
    private void SetMap()
    {
        var frame = new CGRect(0, View.Frame.GetMaxY(), View.Frame.Width, View.Frame.Height);
        mapView = new MapView(View.Frame);
        mapView.MyLocationEnabled = true;
        mapView.BuildingsEnabled = false;
        mapView.SetMinMaxZoom(15f, 18f);
        View = mapView;
    }
    private void SetBottomSheet()
    {
        var bottom = UIScreen.MainScreen.Bounds.Height - UIApplication.SharedApplication.StatusBarFrame.Height;
        bottomSheetViewController = new BottomSheetViewController(100, 300, bottom, true, BottomSheetState.Middle);
        AddChildViewController(bottomSheetViewController);
        View.AddSubview(bottomSheetViewController.View);
        bottomSheetViewController.DidMoveToParentViewController(this);
        bottomSheetViewController.View.Frame = new CGRect(0, View.Frame.GetMaxY(), View.Frame.Width, View.Frame.Height);
    }

如何连接这两个视图(mapView 和 bottomSheetViewController.View),以免丢失 BottomSheet 控件中的向上/向下拖动功能?

即使问题是针对 Xamarin,swift 或 objective-c 的答案也可以做得很好,因为我之后会做"翻译"。

我有一个类似的项目,当时我的解决方案是将 ConsumptionGesturesInView 属性设置为 false

所以你的 SetMap() 方法应该看起来像这样:

private void SetMap()
{
    var frame = new CGRect(0, View.Frame.GetMaxY(), View.Frame.Width, View.Frame.Height);
    mapView = new MapView(View.Frame);
    mapView.MyLocationEnabled = true;
    mapView.Settings.ConsumeGesturesInView = false;
    mapView.BuildingsEnabled = false;
    mapView.SetMinMaxZoom(15f, 18f);
    View = mapView;
}

最新更新