Forum Xamarin.Forms

How to hide iOS Back Button?

RendyDelRosarioRendyDelRosario DOUniversity ✭✭✭
edited June 2014 in Xamarin.Forms

How can i hide the iOS Back Button with Xamarin Forms? When going from a Login Page to Home Page.


  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Instead of trying to navigate forward from your login page you should call PushModalAsync to show your login page when your app starts. This will mean that after login the user will be returned to the main page where the back stack is in the state you want.

  • JflyJfly USMember

    It looks like the question was not answered. How to hide the back button on the navigation bar?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai
    edited June 2014

    Oh you can't currently, sorry (without poking in the platform specific code yourself that is)

  • itcitc USMember

    this.NavigationController.PopToRootViewController (true);

  • chris_riesgochris_riesgo USUniversity ✭✭✭

    @JasonASmith‌ - I've tried this to no avail:

    public override void ViewDidLoad ()
        base.ViewDidLoad ();
        this.NavigationItem.SetHidesBackButton (true, false);

    What other platform-specific solution would you or someone else recommend?

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    @chris_riesgo‌ try overriding ViewWillAppear and if that does not help ViewDidAppear. Could be that the button gets set later by Forms.

  • chris_riesgochris_riesgo USUniversity ✭✭✭

    @rene_ruppert‌ - I'll give it a shot. Thanks.

  • chris_riesgochris_riesgo USUniversity ✭✭✭

    @rene_ruppert‌ - Didn't appear to work either. Note -- I'm using the Forms2Native example method of wrapping a custom UIViewController with a Forms Page Renderer via View Controller Containment.

    Assume Page 1 works fine and takes me to Page 2.
    Previously, with X.iOS, my Page 2 VC was a UITabBarController, where I'd hide the Back button using SetHidesBackButton(true, true) -- worked fine.

    Now, using forms Page 2 is a X.F.Page with Renderer where my child view controller is a UITabBarController. Setting SetHidesBackButton(true, true) has absolutely no effect on the toolbar. In fact, I can't even add buttons. I'm guessing this is because the UITabBarController is now a subview. Any ideas on how I can still use forms, keep my custom VCs, and affect change on the navigation bar?

  • MarshallMarshall USMember ✭✭

    just hide the navigation bar, and implement your own navigation bar, that's how I accomplished this.

  • chris_riesgochris_riesgo USUniversity ✭✭✭

    @Marshall‌ - do you have an example I can take a look at? Especially on rolling my own nav bar.

  • MarshallMarshall USMember ✭✭

    well, I don't really have too much set up, but basically I used a content view, and expanded it to the width of the screen, and then placed some buttons on it. finally, I added it as the top child in a stack layout, and set all the padding, and thickness for it to 0.

  • MarshallMarshall USMember ✭✭

    some code:

    // hide the navigation bar, since we will be creating our own
    NavigationPage.SetHasNavigationBar(this, false);

    // build our custom navigation bar*******************************************
    var myNav = new ContentView();
    myNav.BackgroundColor =;
    myNav.WidthRequest = ParentView.Width;

    var btnBack = new Image("BackButton.png");
    btnBack.GestureRecognizers.add(new TapGestureRecognizer((view)=>

    var title = new Label{ Text = Title, HorizontalOptions = LayoutOptions.CenterAndExpand };

    var toprightlogo = new Image{ Source = ImageSource.FromFile("ImageLogo.png") };

    myNav.Content = new StackLayout
    Padding = new Thickness( 20.0, 0.0 ),
    Orientation = StackOrientation.Horizontal,
    VerticalOptions = LayoutOptions.CenterAndExpand,
    HorizontalOptions = LayoutOptions.FillAndExpand,
    Children =

    this is basically what I did for mine, and it seems to work for me.

  • MarshallMarshall USMember ✭✭

    also, how do you guys do that fancy code snippets you put in your comments? lol

  • chris_riesgochris_riesgo USUniversity ✭✭✭

    @Marshall - just used markdown syntax to make code snippets. Indent 4-spaces for block code, and use back ticks (`) around inline code.

  • chris_riesgochris_riesgo USUniversity ✭✭✭

    @AlexeyB - That worked!! And wasn't super hacky!! Thanks for that bit of detail. Wow.

Sign In or Register to comment.