2

I'm presenting a UITableView modally to provide access to some application settings. When the modal view (root view controller) appears, it has a navigation bar like I expect. However, when one of the options is selected and the next 'UITableView` is popped to the top of the stack, there's no navigation bar.

Storyboard

Here's what one of the child UITableViews looks like:

enter image description here

As far as I know, the two children views should have navigation bars without me having to do anything because they're embedded in a UINavigationController.

I tried dragging a navigation bar to the views but IB will only let me put them inside the UITableView and if I do that, they do appear, but they also go too high in the view and run into the status bar and I can set any layout constraints on them to fix this.

I've scoured the Apple documentation with no luck and found many thread on SO that very, very old and in objective-C.

Can I make these views work together like I'd expect them to or am I going to have to build the child views from scratch?

UPDATE: I'm still trying to get this to work. I've now tried to create a new view controller from scratch. Here's what the view hierarchy looks like:

enter image description here

And you can see in the Storyboard something's not right:

enter image description here

And when I run this in the simulator, I get a new error:

"[UITableViewController loadView] instantiated view controller with identifier "UIViewController-cDg-wV-aMN" from storyboard "Main", but didn't get a UITableView.' But I created the segue by Ctrl-dragging from the cell in the root VC directly to the Table View.

To sum this all up, here's the flow I'm trying to achieve: UIViewController (initial VC) -> UINavigationController (presented modally from the bottom) -> UITableViewController (presented from right to left and with standard navigation bar).

My segues are all set to Show (e.g. Push)

Any help or suggestions would really be appreciated.

Jim
  • 1,260
  • 15
  • 37

1 Answers1

2

Well, I figured out how to fix the problem I was having after coming across another thread that wasn't about the same problem, but it had some advice that tipped me off.

The problem was caused by me creating the segues from the UITableViewCell on my Settings view controller to each of the child UITableViewControllers.

To fix the problem, I simply created the segues between the Settings UITableViewController and each of the child UITableViewControllers.

Hope this helps somebody else someday.

Community
  • 1
  • 1
Jim
  • 1,260
  • 15
  • 37
  • I have a similar problem. Do you call `prepareForSegue` and check the segue identifier to determine which child to present? – royco May 25 '17 at 19:48
  • 1
    @royco, yes, I'm checking segue.identifier to using a simple if-then to determine what to do before segueing. In other cases I'm switching on the identifier when there are more than 2 possibilities. – Jim May 25 '17 at 20:12