Rikard Birgisson
Rikard Birgisson

Reputation: 3

Xamarin forms: Navigation popping without animation on iOS

I'm trying to turn off all animation for popping and pushing pages. I made a custom renderer:

[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationPageRenderer))]

namespace MyNamespace
{
    public class CustomNavigationPageRenderer : NavigationRenderer
    {
        protected override Task<bool> OnPushAsync(Page view, bool animated)
        {
            return base.OnPushAsync(view, false);
        }

        protected override Task<bool> OnPopViewAsync(Page page, bool animated)
        {
            return base.OnPopViewAsync(page, false);
        }

        protected override Task<bool> OnPopToRoot(Page page, bool animated)
        {
            return base.OnPopToRoot(page, false);
        }
}

The pushing works perfectly and never shows animation. The same renderer also works perfectly on Android. But OnPopViewAsync is always called after the pop is made and hence the animation is shown. I'm using Xamarin.Forms v2.3.0.46-pre3. Has anyone else run into this problem and found a workaround?

Upvotes: 0

Views: 654

Answers (1)

SushiHangover
SushiHangover

Reputation: 74174

Two more overrides in your CustomNavigationPageRenderer should do it:

public override UIViewController PopViewController(bool animated)
{
    return base.PopViewController(false);
}

public override UIViewController[] PopToRootViewController(bool animated)
{
    return base.PopToRootViewController(false);
}

Upvotes: 2

Related Questions