1

I just embedded my UINavigationController into a UITabBarController. I can no longer see my view title or edit button. Please see storyboard below. How do I make the edit button visible again?

My Storyboard: My Storyboard

Adeel Miraj
  • 2,472
  • 3
  • 22
  • 32
Allie
  • 57
  • 7

1 Answers1

1

Rather than the following organization (which you're currently using):

NavController -> TabBarController -> ViewControllerA
                                  \
                                   -> ViewControllerB

You must do the following:

TabBarController -> NavControllerA -> ViewControllerA
                 \
                  -> NavControllerB -> ViewControllerB

UITabBarControllers should always be the root view. Each child view controller needs its own navigation controller to achieve the navigation bar + tab bar effect you desire. Here is an example of what the structure should look like:

Storyboard laid out with TabBarController at the root.

As for adding navigation items / titles to each view controller once you've done the above, make sure to drag Navigation Items onto each view controller. You can find the Navigation Item in the Object Library at the bottom of the Utilities view:

Navigation Item in the Object Library

Mark
  • 7,167
  • 4
  • 44
  • 68
  • When I was first learning how to embed into a UITabBarController, I was told I had to have the NavController out front. See http://stackoverflow.com/q/40509479/7100251 – Allie Nov 09 '16 at 15:09
  • That may work in some cases, but you'll end up encountering weird errors (like the one you're encountering). UINavigationControllers are designed to be embedded in UITabBarControllers, not the other way around. There is a similar question and answer here: http://stackoverflow.com/questions/27422054/how-to-implement-tab-bar-controller-with-navigation-controller-in-right-way – Mark Nov 09 '16 at 17:40
  • I tried that approach, but it only cut off more from the top of my view controllers. – Allie Nov 09 '16 at 23:40
  • Not exactly sure what you mean by that. You may be encountering a different problem setting up your view controllers like I have outlined above. You could give me a link to your project and I could try fixing it. Or you could open another question for the cut off issue. – Mark Nov 09 '16 at 23:46
  • How can I give you a link to my project? It is in XCode. – Allie Nov 10 '16 at 01:52
  • You can create a public repository on GitHub and share the link here. Or zip up your project and upload it to a file hosting site like Dropbox or Google Drive. – Mark Nov 10 '16 at 03:25
  • Ah, you'll need to compress your entire project directory rather than just the xcodeproj file (compress the folder that contains the xcodeproj file and all your other files). – Mark Nov 10 '16 at 03:39
  • I've updated the question to include adding a navigation item. I also took a look at your project and fixed up the storyboard: https://drive.google.com/open?id=0B5xMSwZtXPBHM1hiUmhsWUpTbkk – Mark Nov 11 '16 at 01:39
  • Is there any way you could attach a picture of it? For some reason I cannot open it. – Allie Nov 11 '16 at 03:25
  • If you take a look at the actual storyboard file, I believe Drive adds a .xml to the end. Try removing that extension and just use .storyboard. – Mark Nov 11 '16 at 03:26
  • The file is not compatible. I need to update to Xcode 8 but my computer will not allow it. Anyway you could send a screenshot? – Allie Nov 11 '16 at 03:33
  • Updated the answer with a screenshot of the reorganization I did. – Mark Nov 11 '16 at 03:38