objective-cnavigationnavigationbarcontainer-view

Custom navigation and container views


What I want

A completely custom navigation bar, which will persist and allow user interaction through custom modal transitions.

What I've done

I've built a parent view controller that contains a Container View on the bottom and a view (the custom navigation bar) on the top. The Container View embeds a view controller that can present other view controllers modally.

The view controllers that are presented modally use a custom transition (UIViewControllerTransitioningDelegate) to pop up from the bottom and only occupy the part of the view controller at the bottom (i.e. leaving the menu visible).

When the first view controller is presented modally, the custom navigation menu can still be interacted with. However, if the first modally presented view controller in turn presents another view controller, then the custom navigation bar does not respond to user interaction.

|  NAV BAR  |             
|-----------|             |------------|               |------------|              
| Container |             |   View     |               |    View    |             
|   view    |-> EMBED ->  | Controller |-> Presents -> | Controller |-> Presents ->
|           |             |            |    Modally    |    1st     |    Modally   

(cont)

  |------------|
  |    View    |
->| Controller |
  |     2nd    |

When the first view controller is presented modally, the navigation bar still responds to touches. When the second one (and any others down that line (i.e. 3rd, 4th...)) are presented the navigation bar is still visible but does not respond to user touches.

There is an example project on Github that illustrates the problem I'm having.

What my problem is

I'd like to be able to tap on the navigation bar no matter how many view controllers I have presented modally.

Should the way I'm approaching this work?

What is the best way to accomplish what I want to do? Is there a standard way to create completely custom navigation bars (i.e. several buttons, custom height, etc)?


Solution

  • Please change the modal presentation style for second view controller in file CVTFirstViewController.h according to Github project.

    Use this code

         secondViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    

    instead of

         secondViewController.modalPresentationStyle = UIModalPresentationCustom;