{"id":13099,"date":"2014-04-22T01:32:51","date_gmt":"2014-04-21T20:02:51","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=13099"},"modified":"2022-01-11T12:08:12","modified_gmt":"2022-01-11T06:38:12","slug":"menu-listing-on-navigation-bar-in-iphone","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/menu-listing-on-navigation-bar-in-iphone\/","title":{"rendered":"Menu Listing on Navigation bar in iPhone"},"content":{"rendered":"<p>Hi Everyone,<\/p>\n<p>Though there are many native components which are provided in \u00a0iPhone 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.<\/p>\n<p>For this customize our root navigationController inherited from \u00a0<strong>UINavigationController\u00a0<\/strong>and add a tableview inside that controller, here we will decide through how much UIViewControllers \u00a0we will navigate. The table (drop menu) will be shown or hide on the click of the bar button added on the navigation bar.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full \" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/01\/34.jpg\" alt=\"\" width=\"860\" height=\"360\" \/><\/p>\n<p>Here&#8217;s the implementation in \u00a0TestViewNavigationController.m<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.08.11-AM1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13109\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.08.11-AM1.png\" alt=\"\" width=\"853\" height=\"442\" \/><\/a><\/p>\n<p>Here are the table view data source and delegate methods handled.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.09.15-AM.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13110\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.09.15-AM.png\" alt=\"\" width=\"934\" height=\"460\" \/><\/a><\/p>\n<p>And now the Bar button is shown and hide through these methods<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.29.45-AM.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13111\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.29.45-AM.png\" alt=\"\" width=\"914\" height=\"535\" \/><\/a><\/p>\n<p>We will add a utility class of <strong>NSObject<\/strong> type, where we will define the class methods \u00a0to 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.<\/p>\n<p>Here are the methods declared in\u00a0<strong>TestUtility.h<\/strong><\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.45.15-AM.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13112\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-12.45.15-AM.png\" alt=\"\" width=\"1008\" height=\"122\" \/><\/a><\/p>\n<p>Now the\u00a0<strong>TestUtility.m \u00a0<\/strong>where methods are defined for handling the navigation between the viewControllers and bar button configuration on navigation bar<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-1.04.51-AM1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13114\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-1.04.51-AM1.png\" alt=\"\" width=\"1039\" height=\"738\" \/><\/a><\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-1.09.44-AM.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13115\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-1.09.44-AM.png\" alt=\"\" width=\"994\" height=\"300\" \/><\/a><\/p>\n<p>Here&#8217;s one of the viewController \u00a0example where we add a bar button to the navigation bar and handles the touch event to remove the tableview from that particular viewController.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-1.21.00-AM2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-13120\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/04\/Screen-Shot-2014-04-22-at-1.21.00-AM2.png\" alt=\"\" width=\"1004\" height=\"574\" \/><\/a><\/p>\n<p>This is how the menu List \u00a0is presented on the tap of \u00a0bar button and one can easily navigate through the respective viewControllers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi Everyone, Though there are many native components which are provided in \u00a0iPhone 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 \u00a0UINavigationController\u00a0and [&hellip;]<\/p>\n","protected":false},"author":116,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":4},"categories":[7,1400],"tags":[4848,1401],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/13099"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=13099"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/13099\/revisions"}],"predecessor-version":[{"id":54522,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/13099\/revisions\/54522"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=13099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=13099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=13099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}