Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to display a view controller as a modal from tab bar controller

koby1koby1 Member ✭✭

When I select an item from my tab bar supposedly the view will appear as a modal over where I was at may last view.


Best Answer


  • koby1koby1 Member ✭✭

    @LandLu, is index based on my tab bar items that is connected to particular views?

  • LandLuLandLu Member, Xamarin Team Xamurai

    @koby1 This index is the tab items' index. You can choose other conditions. i.e. if (viewController is ParticularViewController), this can disable the particular items' default displaying and present a new modal vc.

  • koby1koby1 Member ✭✭

    @LandLu thanks! How about if I just want to display the tabbar on the bottom of my new view that is displayed by clicking a label from a view controller I initialize from one of my tabs

  • koby1koby1 Member ✭✭

    @LandLu also when I dismiss the presented view controller it just adds the tabbar on the bottom of the current view. What I want is if I could return from I where I am from may tab bar controller

  • LandLuLandLu Member, Xamarin Team Xamurai

    display the tabbar on the bottom of my new view

    The new view controller will be presented as a modal view without the tabbar. I'm confused about what you want to display?

    What I want is if I could return from I where I am from may tab bar controller

    Does this mean when you dismiss the modal view, you want your tabbar controller navigate to the tab which you selected just now?
    If so, record the index you have selected when you come back use TabbarController.SelectedIndex = to change the current selected index.
    Moreover try to describe more clearly about your issue, maybe post some screenshots could help us understand your requirement.

  • koby1koby1 Member ✭✭

    When I tapped on tab #5 the tab bar is removed which is correct but when I tap a close button from the presented view controller, I wish to go back from the tab on where I was before tapping tab #5. For example I'm on tab #2 before tapping tab #5, if I close the presented view controller I i should be at the view controller of tab #2

  • LandLuLandLu Member, Xamarin Team Xamurai

    @koby1 The code I post will get this effect. Since when you tap the #5, ShouldSelectViewController returns false, the tabbar's selected item will not be changed. So when you return back the tabbar controller will keep the original selected index.

  • koby1koby1 Member ✭✭

    @LandLu I missed out the return false, I added it on my code and it works! Thanks man!

Sign In or Register to comment.