Forum Xamarin Xamarin.iOS

What's the best way to show a menu like dialog from a tab bar?

DeanCleaverDeanCleaver USMember ✭✭✭

I have a situation where I may need to ask the user anything from none to 5 questions. Obviously, none is easy. One or two, I can present sequential menus with a "Yes" and "No" button. But if there's more than 2, ideally I'd like to show a "menu" so it's similar to the first two, but with a Label left and a UISwitch on the right so they can select Yes or No individual to each one then click ok.

I know we're not supposed to subclass the UIActionSheet now - so what's a good alternative that I can make appear like a UIActionSheet (possibly the sliding up, but also the shading of the rest of the UI until it's hidden etc.)?


  • JF.0444JF.0444 USMember ✭✭✭

    You do not need to subclass UIActionSheet. You can create your own view controller with all the logic you need for the pop over. Then just set the size of the pop over and present like:

    viewController.PreferredContentSize = new CGSize (300, 300);
    viewController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
    var popUp = new UIPopoverController (viewController);

    then to present from bar button PresentFromBarButtonItem() or PresentFromRect() to show from any view

    popUp.PresentFromBarButtonItem (SomeBarButton, UIPopoverArrowDirection.Up, true);


    popUp.PresentFromRect(SomeView.Bounds, SomeView,  UIPopoverArrowDirection.Any, true);
  • DeanCleaverDeanCleaver USMember ✭✭✭

    I thought the UIPopoverController was only for iPad?

  • JF.0444JF.0444 USMember ✭✭✭

    Yes that is true, I apologize I didn't realize you needed a solution for iphone.

  • JF.0444JF.0444 USMember ✭✭✭

    In that case I would create a custom view. You can then animate it up from bottom of screen by animating the change with a UIView.Animate () block. As far as shading out the rest of the screen you apply a semi translucent view over your view controller before presenting the sliding view.

    I am actually in the process of creating a xamarin component for sliding views, either by dragging the view up or by tapping it. Not all of that may apply to your scenario but I think its customizable enough to fit your needs, or you can take out the code you need.

    Source code at

    If needs be I may be able to make you a sample project when I am by a computer.

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Here's an (ObjC) implementation of an iPad-style popover for iPhone:

    It uses a popover presentation style Adaptive Segue.

  • JF.0444JF.0444 USMember ✭✭✭
    edited September 2016

    Interesting, was not aware of adaptive segue. Seems like this would require everything be on the same storyboard though which might be unwanted in large projects.

Sign In or Register to comment.