xamarin/Xamarin.Forms

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

Open

#4,675 opened on Dec 7, 2018

 (2 comments) (3 reactions) (0 assignees)C# (1,926 forks)batch import
a/gestures 🖖e/6 :clock6:help wantedi/lowinactivep/iOS 🍎t/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Contributor guide