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

SelectableWrapPanel throws exception when try to select any item on iOS #867

Closed
smartestimatorapp opened this issue Aug 5, 2024 · 1 comment

Comments

@smartestimatorapp
Copy link

35cef961-2635-479b-9346-875f0b40ef5a
report-2516795330540009999-dd74d284-83e8-4c4d-842b-04d37e509a1a.txt

Description

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue (.NET Maui or Xamarin.Forms?):
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
  • Nuget Packages:
  • Affected Devices:

Screenshots

@Santiago5050
Copy link
Contributor

Hi @smartestimatorapp,

Thank you for reporting this issue. The crash you're experiencing with the SelectableWrapPanel inside a PopupPage is related to the Mopups library, as described in this issue.

To prevent the app from crashing, please add the following workaround code to your MauiProgram.cs file when the app is being created:

//Workaround for: https://github.com/LuckyDucko/Mopups/issues/97
#if IOS
    Mopups.Platforms.iOS.PopupPageHandler.Mapper.AppendToMapping("FixingMopupCrash", (handler, view) =>
    {
        (view as Page).Appearing += (s, e) =>
        {
            var eventName = "DescendantRemoved";
            var eventInfo = typeof(Element).GetEvent(eventName);
            var descendantRemovedEvent = typeof(Element).GetField(eventName, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            if (descendantRemovedEvent.GetValue(view) is not Delegate eventDelegate)
            {
                return;
            }

            foreach (var d in eventDelegate.GetInvocationList())
            {
                eventInfo.RemoveEventHandler(view, d);
            }
        };
    });
#endif

Let us know if you have any questions!

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants