2
votes

I'm trying to complete my first iOS application.

My storyboard layout is this:

Navigation Controller
'-> View Controller
    '->Tab Bar Controller
       |->Table View Controller
       |  '->View Controller
       '->Table View Controller
          '->View Controller

All of the views are shown with a push (not modal) so need back navigation. Problem is when I go back from the last View to the Table View, viewWillAppear doesn't fire. So I added navigation controllers:

Navigation Controller
'-> View Controller
    '->Tab Bar Controller
       |->Navigation Controller
       |  '->Table View Controller
       |     '->View Controller*
       '->Navigation Controller
          '->Table View Controller
             '->View Controller

This fixes the viewWillAppear problem, but then the tab bar still shows at the bottom and i get an extra navigation bar in the table view and final view (see below - corresponds to * above). Pressing the top "< Back" button takes me back to the very first view (wrong), pressing the second "< Back" button takes me back to the table view (correct)

Questions:

  • What am I doing wrong here???
  • When should a view have a NavigationController? Is it ok to have one for the whole storyboard or should I have more.
  • If I put a navigation controller after a tab bar, the bottom tab bar stays. How do I get rid of it?
  • Should I avoid tab bars?

enter image description here

UPDATE:

This is bizarre. If I recreate the story board I can narrow it down to the initial view controller / navigation controller pair. No idea what could be the issue as swapping these out for a fresh pair solves it.

1
Have you set the frame of first navigation controller..? Please show your code snippet.VRAwesome
@SweetAngel It is all in storyboard. I trawled through the code to see if there was any difference between it but couldn't find one. I think the problem may have been making a NavigationItem and then later embedding in a NavigationController.geometrikal

1 Answers

1
votes
  • From Apple UITabbarController Docs

    You can use navigation controllers or custom view controllers as the root view controller for a tab. If the root view controller is a navigation controller, the tab bar controller makes further adjustments to the size of the displayed navigation content so that it does not overlap the tab bar.

  • ViewWillAppear of your TableVC should be called regardless of it embedded in navigationController.

  • Avoiding tab bars or not and single navigation controller for the storyboard are app design related.