0

I my app, I create a custom navigation rendered, OnPushAsync and PopViewController are override and it works on iOS.

public class NavRenderer : NavigationRenderer
            {
                protected override async Task<bool> OnPushAsync(Page page, bool animated)
                { ...
    }


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

Trying to do the same (?) on Android, how can override OnPushAsync and PopViewController?

Tx

doxsi
  • 1,002
  • 19
  • 42

1 Answers1

1

You can override these methods in android renderer to push & pop Pages

public class NavRenderer : NavigationRenderer
{
    public NavRenderer(Context context) : base(context)
    {

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

These are the equivelent methods in your iOS renderer to push & pop Controllers

public class NavRenderer : NavigationRenderer
{
    public override void PushViewController(UIViewController viewController, bool animated)
    {
        base.PushViewController(viewController, animated);
    }

    public override UIViewController PopViewController(bool animated)
    {
        return base.PopViewController(animated);    
    }
}
R15
  • 13,982
  • 14
  • 97
  • 173
  • Tx. Do you Know the equivalent to NavigationBar.BarTintColor ,(i use it on iOS nav rendered to change navigation bar color.) – doxsi Nov 27 '18 at 11:48
  • You can try something like this `((NavigationPage)Xamarin.Forms.Application.Current.MainPage).BarBackgroundColor = Color.Blue;` – R15 Nov 27 '18 at 12:26