xamarin/Xamarin.Forms

MasterDetailPage Swipe animation intercepts touch effects meant for children of DetailPage in iOS

开放

#4,675 创建于 2018年12月7日

 (2 条评论) (3 个反应) (0 位负责人)C# (1,926 个派生)batch import
a/gestures 🖖e/6 :clock6:help wantedi/lowinactivep/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Description

I used the tutorial at https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/effects/touch-tracking to implement touch in a Xamarin.Forms application. I noticed when dragging a child element that the touch tracking would be lost if in a Detail of a Master/Detail page in iOS. I was able to confirm that the swipe of the detail page to expose the master page was intercepting the touch effects.

This is not an issue in Android or UWP.

Steps to Reproduce

  1. Download the source from the https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/effects/touch-tracking
  2. Upgrade to latest Xamarin.Forms nuget package.
  3. Add new item - a Xamarin.Forms MasterDetailPage. Don't change name so you'll get MasterDetailPage1.xaml, MasterDetailPage1Master.xaml, MasterDetailPage1Detail.xaml, etc.
  4. Ensure the namespaces just added match the namespace of the project.
  5. In the newly created MasterDetailPage1Master.xaml.cs file, change a menu item. I did this: new MasterDetailPage1MenuItem { Id = 2, Title = "Box View Dragging Page", TargetType = typeof(BoxViewDraggingPage) }
  6. Change the constructor in App.cs to: MainPage = new NavigationPage(new MasterDetailPage1());
  7. Run the app and exercise the Box View Dragging Page link and this will expose the issue.

I noticed the issue in an older version 3.2 so I upgraded through 3.3 and into the latest 3.4 with no effect.

Expected Behavior

Dragging the box all over the screen

Actual Behavior

Only drag it about 5 pixels before only the swipe of the detail page is all that is activated.

Work Around:

On the page where dragging is wanted that doesn't swipe the detail page, override the OnAppearing and get a reference to the Master page and set IsGestureEnabled=false. Something like this:

protected override void OnAppearing()
{
    base.OnAppearing();

    if(Device.RuntimePlatform == Device.iOS)
    {
        MasterDetailPage md = this.Parent?.Parent as MasterDetailPage;
        if(md != null)
        {
            md.IsGestureEnabled = false;
        }
    }
}

Basic Information

  • Version with issue: Xamarin.Forms 3.4.0.1008975
  • Last known good version: n/a.
  • IDE: Visual Studio 2017 15.9.3
  • Platform Target Frameworks: iOS
    • iOS: 12.1
    • Android: n/a
    • UWP: n/a
  • Android Support Library Version: n/a
  • Nuget Packages:
  • Affected Devices:

Screenshots

Uploaded replicated issue movie to Youtube: https://youtu.be/iaM0S5lt4Wg

贡献者指南