Search code examples
iosuinavigationcontrolleruicontainerviewios10imessage

How to keep navigation bar from disappearing with MSMessagesViewController -> UIContainerView -> UINavigationController -> UITableViewController?


I am trying to put a navigation controller with a table view controller within an iMessage app (iOS 10). This seems to work when I put the UINavigationController within an UIContainerView within the MSMessagesViewController.

Appearance when compact.

However, this breaks when in expanded view. The UINavigationBar that the controller has disappears.

Broken appearance when expanded.

How can I remedy this, or am I taking the wrong approach?


Solution

  • So in my case, I was using Storyboards, so I will add in the Storyboard solution to this.

    Similar to DLee's answer, the top constraint needs to be set to the "Top Layout Guide" not "Top." Here's what it looks like in a Storyboard:

    Container View.top = Top Layout Guide.bottom

    In my case, I used a Container View to hold everything, so with this having the top layout guide set as the top constraint, it made everything go in the right place.

    In my post, I originally used the "Top" which was what caused parts of the iMessage app (specifically the navigation bar) to disappear.