Search code examples
iphoneipaduinavigationcontrolleruisegmentedcontrolrightbarbuttonitem

Adding Segment controller to place that already has one


I have menu button that is being put in the Navigation controller on every page in the rightBarButtonItem (customer wishes) from a my BaseViewController (all other classes inherit from this).

I want to add a segment controller next to the menu button on one of the pages.

Is there a way to just add a segment controller next to it without replacing one or the other?

I have seen examples of adding 2 items into one controller, but I need to add them at separate times.


Solution

  • You will need to create a view that contains the menu button and the segmented button and then create a UIBarButtonItem using initWithCustomView:(UIView *)customView and pass the view with the buttons. Then set rightBarButtonItem to this barButtonItem.