Clear Navigation Stack on iOS

Hello Everyone, i hope i can get some help here. I've been going crazy for weeks now!

I have an app functionning perfectly, but the only clue right now is i wish to clear the navigation stack, each time i reach a specific view controler.

say i have 5 views A;B;C;D;E, and during navigation i move from A->B->C->D->E, now i have a button which can bring me back to controler A, but now, when i press back icon on navigation bar, i wish to close the application (not go back to view controler E->D->C->B->A).

Please is there anyway to to this on Xamarin C#?

Any help shall be greatly appreciated. Thanks !!

Best Answer

  • ProgrammerCMRProgrammerCMR US ✭✭
    Accepted Answer

    Hello all,
    finally found out how to make this possible.
    As a matter of fact, my problem was not to allow users to go back previous page when on a specific page.
    the answer was just to hide the back button when the user is on that page

    this.NavigationItem.SetHideBackButton(true, false);

    You put this when initialising the page, in the ViewDidLoad, and ViewDidAppear methods.

    This way the back button won't appear on this page.

    Thanks all!!

Answers

  • TedRogersTedRogers USMember ✭✭✭✭
    edited November 2017

    Not sure you would get approved for the app store with this in your app but you can call "exit(0)" to close your application.

    Put this in the top of your class and call exit(0) at the proper time.

    [DllImport("__Internal", EntryPoint = "exit")]

  • ProgrammerCMRProgrammerCMR USMember ✭✭
    Accepted Answer

    Hello all,
    finally found out how to make this possible.
    As a matter of fact, my problem was not to allow users to go back previous page when on a specific page.
    the answer was just to hide the back button when the user is on that page

    this.NavigationItem.SetHideBackButton(true, false);

    You put this when initialising the page, in the ViewDidLoad, and ViewDidAppear methods.

    This way the back button won't appear on this page.

    Thanks all!!

Sign In or Register to comment.