Though there are many native components which are provided in iPhone for making better and effective applications, but drop down is still missing. But with the amalgamation of certain components and animation we can make a drop down menu to navigate through view controllers.
For this customize our root navigationController inherited from UINavigationController and add a tableview inside that controller, here we will decide through how much UIViewControllers we will navigate. The table (drop menu) will be shown or hide on the click of the bar button added on the navigation bar.
Here’s the implementation in TestViewNavigationController.m
Here are the table view data source and delegate methods handled.
And now the Bar button is shown and hide through these methods
We will add a utility class of NSObject type, where we will define the class methods to handle the action on rows in the table view and also define the configuration of the bar button on navigation bar which will be added to respective viewControllers navigation bar, when called from there.
Here are the methods declared in TestUtility.h
Now the TestUtility.m where methods are defined for handling the navigation between the viewControllers and bar button configuration on navigation bar
Here’s one of the viewController example where we add a bar button to the navigation bar and handles the touch event to remove the tableview from that particular viewController.
This is how the menu List is presented on the tap of bar button and one can easily navigate through the respective viewControllers.