Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAUI iOS - DrawingView inside ScrollView does not draw. Attempted drawing trigger scrolling instead of drawing. (works fine on android) #1807

Closed
2 tasks done
mahesh139 opened this issue Apr 10, 2024 · 16 comments
Assignees
Labels
area/views Issue/Discussion/PR that has to do with Views bug Something isn't working unverified

Comments

@mahesh139
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When DrawingView is used inside scroll view, attempt to draw triggers scrolling on iOS and drawing does not work. this works fine on android.

I am trying to migrate Xamarin Forms app to MAUI and need to replace signature pad on the form with drawing view. this is a blocker for my migration.

Expected Behavior

DrawingView inside scroll view must work fine on iOS like android. Drawing must not trigger scrolling.

Steps To Reproduce

I have provided link to reproduction repository and video with demo app.

Steps: (problem only on iOS, android works fine)

Create Default MAUI App
Add community toolkit to use drawing view
Updated MauiProgram.cs and add .UseMauiCommunityToolkit() to builder.
Update main page xaml to have drawing view inside scroll view, make sure there is enough content before and after drawing view to have scroll bar on the page
try to draw on drawing view (vertically), page scrolls instead of drawing on drawing view.

MAUI.DrawingView.mp4

Link to public reproduction project repository

https://github.com/mahesh139/MAUIDrawingView

Environment

- .NET MAUI CommunityToolkit:8.0.1
- OS:Windows 10
- .NET MAUI:8.0.7

Anything else?

No response

@mahesh139 mahesh139 added bug Something isn't working unverified labels Apr 10, 2024
@vhugogarcia vhugogarcia added the area/views Issue/Discussion/PR that has to do with Views label Apr 13, 2024
mikelor added a commit to mikelor/Maui that referenced this issue Apr 15, 2024
…Pins Page sample show user. Updated MapHandler.Windows RemoveAllPins() to add back user location if showing user.
@zleao
Copy link

zleao commented Apr 22, 2024

I have the same issue, when placing the DrawingView inside a CollectionView.
Problem only on iOS. Android works great.
It looks like the swipping event is being passed to from the DrawingView to the Parent Control (CollectionView or ScrollView)

@VladislavAntonyuk VladislavAntonyuk self-assigned this Apr 24, 2024
brminnick added a commit that referenced this issue Apr 27, 2024
…ter adding a Pin to the Map when IsShowingUser is set to True #1801 (#1817)

Implementing Fix for Issue #1807. Modify Windows Map Pins Page sample show user. Updated MapHandler.Windows RemoveAllPins() to add back user location if showing user.

Co-authored-by: Brandon Minnick <[email protected]>
@imuller
Copy link

imuller commented Apr 29, 2024

Same issue here on iOS. Also when placed inside a Modal page that scrolls when the user interacts with it.

@imuller
Copy link

imuller commented Apr 29, 2024

Possible solution might be this: https://github.com/xamarin/SignaturePad/blob/master/src/SignaturePad.iOS/InkPresenter.cs

See line: 34

// If you put SignaturePad inside a ScrollView, this line of code prevent that the gesture inside
// an InkPresenter are dispatched to the ScrollView below
public override bool GestureRecognizerShouldBegin (UIGestureRecognizer gestureRecognizer) => false

@imuller
Copy link

imuller commented May 13, 2024

Other solution is to use SkiaSharp: dotnet/maui#18758

@bijington
Copy link
Contributor

bijington commented May 13, 2024

2 things:

  • how many cracks do you have on that screen 😂

  • I agree we should fix something around this but I would question the UX of allowing a user to draw inside a scrollable page. An alternative solution which I think bring a better user experience is to allow the user to tap on the signature area and then show the DrawingView

@mahesh139
Copy link
Author

mahesh139 commented May 13, 2024

2 things:

  • how many cracks do you have on that screen 😂
  • I agree we should fix something around this but I would question the UX of allowing a user to draw inside a scrollable page. An alternative solution which I think bring a better user experience is to allow the user to tap on the signature area and then show the DrawingView

On a lighter note... it has less cracks than MAUI :) and doing its testing job nicely. I will do something about phone once MAUI is stable and i can complete my migration hehe.

Back to Problem:
When you have a form with question / answers and signatures in between, it will be bad experience for users to tap and go out for signature and than come back and that too multiple times. works fine in android and expectation is that it must work fine for iOS too.

@bijington
Copy link
Contributor

I don't agree that it would be a bad user experience. Having that explicit mode makes more sense to me. Imagine a user attempts to scroll and then accidentally signs in the box instead, if your app requires the user to sign you're opening up to accidental signatures which sounds bad.

Anyway I don't disagree that we shouldn't try and fix something

@zleao
Copy link

zleao commented May 15, 2024

I solved this problem, by addding the ios:ScrollView.ShouldDelayContentTouches="false" to the ScrollView that contains the DrawingView:

<ContentView
...
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls">

    <ContentView.Content>
        
        <ScrollView ios:ScrollView.ShouldDelayContentTouches="false">
...

more info here: https://learn.microsoft.com/en-us/dotnet/maui/ios/platform-specifics/scrollview-content-touches?view=net-maui-8.0

@bijington
Copy link
Contributor

@zleao thank you for sharing that! I think we should add that detail to the documentation for the toolkit and that might be all we can do for now.

@bijington
Copy link
Contributor

MicrosoftDocs/CommunityToolkit#423

@mahesh139
Copy link
Author

Thanks @zleao ios:ScrollView.ShouldDelayContentTouches="false" works fine.

@bijington
Copy link
Contributor

I am going to close this issue now that the documentation covers the solution

@mnidhk
Copy link

mnidhk commented May 21, 2024

Maybe the ShouldDelayContentTouches works for a scrollview but i use the drawingpad in a tableview which has scroll capabilities. On iOS it still scrolls the tableview when to want draw a signature. When i put my finger at the drawingpad, wait for a couple milliseconds, then i can write the signature ( in one stroke, up and down, right and left) Second stroke i need to do the same,
Works great on Android. (on XF, it also works great on iOS with the signature pad nuget)
Another workaround/possibility when using the drawing pad in not a scrollview?

@zleao
Copy link

zleao commented May 23, 2024

@mnidhk
The TableView in .Net MAUI is mapped to a UITableView for iOS (see here).

The UITableView is a subclass of UIScrollView, which means it has the same capabilities, like the delayContentTouches. You might not be able to directly use the ios:ScrollView.ShouldDelayContentTouches="false" (Haven't tried it so not sure), but maybe you can add this behavior by overriding the TableViewRenderer for iOS

@zleao
Copy link

zleao commented May 25, 2024

@mnidhk
FYI, I've wrote a blog post with an explanation of a possible solution for this problem, for ScrollView and TableView.

https://medium.com/medialesson/how-to-use-a-drawingview-inside-a-scrollable-layout-in-net-maui-2a080e32cdb4

@mnidhk
Copy link

mnidhk commented May 27, 2024

@mnidhk FYI, I've wrote a blog post with an explanation of a possible solution for this problem, for ScrollView and TableView.

https://medium.com/medialesson/how-to-use-a-drawingview-inside-a-scrollable-layout-in-net-maui-2a080e32cdb4

Thnx for the info! Working great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/views Issue/Discussion/PR that has to do with Views bug Something isn't working unverified
Projects
None yet
Development

No branches or pull requests

7 participants