AlexandrNikulin / AnimationNavigationPage

AnimationNavigationPage is a NavigationPage with custom transitions animation effects.
Apache License 2.0
237 stars 37 forks source link

Unhandled managed exception: Popped page does not appear on top of current navigation stack #61

Closed pmahend1 closed 4 years ago

pmahend1 commented 4 years ago
Unhandled managed exception: Popped page does not appear on top of current navigation stack, please file a bug. (System.NotSupportedException)
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPopViewAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00059] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:322 

Description

If UIEdgeSwipe is stopped halfway , then the page hangs, you cant do it again ,however it remains on same page. If we click on soft back button instead of popping once its popping twice and crashed

Steps to Reproduce

  1. Create PageRenderer for a content page

  2. In the renderer

    
    public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            UIApplication.CheckForEventAndDelegateMismatches = false;
            if (NavigationController != null)
            {
                if(NavigationController.InteractivePopGestureRecognizer is UIScreenEdgePanGestureRecognizer edgeReco)
                {
                    if (!edgeReco.Enabled)
                    {
                        edgeReco.Enabled = true;
                        NavigationController.InteractivePopGestureRecognizer.Delegate = new NavDelegate();
    
                    }
                    else
                    {
                        NavigationController.SetNeedsUpdateOfScreenEdgesDeferringSystemGestures();
                        NavigationController.InteractivePopGestureRecognizer.Delegate = new NavDelegate();
    
                    }
                }
            }
        }
  3. Delegate

private class NavDelegate : UIGestureRecognizerDelegate {
        //https://stackoverflow.com/questions/21794778/prevent-uiscrollviews-uipangesturerecognizer-from-blocking-uiscreenedgepangestu
        public override bool ShouldBeRequiredToFailBy (UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer) {
            Debug.WriteLine (MethodBase.GetCurrentMethod ().Name);
            return true;
        }

        public override bool ShouldBegin (UIGestureRecognizer recognizer) {
            Debug.WriteLine (MethodBase.GetCurrentMethod ().Name);
            return true;
        }

        public override bool ShouldReceivePress (UIGestureRecognizer gestureRecognizer, UIPress press) {
            Debug.WriteLine (MethodBase.GetCurrentMethod ().Name);
            return true;
        }

        public override bool ShouldRecognizeSimultaneously (UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer) {
            Debug.WriteLine (MethodBase.GetCurrentMethod ().Name);
            return true;

        }

        public override bool ShouldRequireFailureOf (UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer) {

            Debug.WriteLine (MethodBase.GetCurrentMethod ().Name);
            return false;
        }
  1. In any nav page use UiEdgeSwipe halfway through and return.

  2. Click on Softback button. In the forms it shows Navigation Stack to be 2 , but however PopAsync() gets called twice internally.

Expected Behavior

Should retain state and not pop twice if Count is just 2

Actual Behavior

Popping page twice when Navigation stack is just 2 from iOS navigation renderer and causing the app to crash

Basic Information

Screenshots

ezgif com-video-to-gif

Reproduction Link

XamarinFormsIssues/UISwipeBackIssue