I need to implement menu for iOS like android.menu
means button on navigation bar(right side).
If I click that menu will display.
I am using a storyboard.
I need to implement menu for iOS like android.menu
means button on navigation bar(right side).
If I click that menu will display.
I am using a storyboard.
I would use a Popover rather than a complete custom menu. On iPhones it is suggested to use a full screen modal presentation rather than a popover menu, but it is still possible.
This image is from the Popover documentation.
For more details on how to do it, see this answer.
So you want something like this:
Even works in landscape:
I think it's going to take forever for me to explain :D
Basically I created a custom UINavigationController as mentioned in the comments above, called it ActionBarNavigationController
From this custom UINavigationController, I added a custom UIView to display the
ActionBar
with the drop down button on the right.The drop down menu is a
UITableView
with a populated list of your choice.I used
protocol
in iOS to handle the tap even on each row of the drop down menu.Everything was done purely in code. You can add these files to your project if you like, I've provided the code in full below where necessary.
AppDelegate.m
ViewController.h
ViewController is just your ordinary UIViewController that conforms to the
ActionBarNavControllerDelegate
that I created in the class below. Make sure you include it.ViewController.m
ActionBarNavController.h
This ActionBarNavController contains an instance of the ActionBar custom view. It handles the interactions of the user tapping on the drop down button.
ActionBarNavController.m
ActionBar.h
This ActionBar class is the custom UIView to show the action bar with drop down button.
ActionBar.m
DropDownCell.h
This custom UITableViewCell class controls the look and feel of the drop down menu cells.
DropDownCell.m
Drop Down Icon
androidMenuButton@1x, @2x, @3x