title: Tab bar controller inside a navigation controller, or sharing a navigation root view
body: <p>I'm trying to implement a UI structured like in the <em>Tweetie</em> app, which behaves as so: the top-level view controller seems to be a navigation controller, whose root view is an "Accounts" table view.  If you click on any account, it goes to the second level, which has a tab bar across the bottom.  Each tab item shows a different list and lets you drill down further (the subsequent levels don't show the tab bar).</p>
  
  <p>So, this seems like the implementation hierarchy is:</p>
  
  <ul>
  <li><code>UINavigationController</code>
  
  <ol>
  <li><em>Accounts</em>: <code>UITableViewController</code></li>
  <li><code>UITabBarController</code>
  
  <ol>
  <li><em>Tweets</em>: <code>UITableViewController</code>
  
  <ul>
  <li>Detail view of a tweet/user/etc</li>
  </ul></li>
  <li><em>Replies</em>: <code>UITableViewController</code></li>
  <li>...</li>
  </ol></li>
  </ol></li>
  </ul>
  
  <p>This seems to work[^1], but appears to be unsupported according to the SDK documentation for <code>-pushViewController:animated:</code> (emphasis added):</p>
  
  <blockquote>
    <p><em>viewController</em>: The view controller that is pushed onto the stack. <strong>It cannot be an instance of tab bar controller.</strong></p>
  </blockquote>
  
  <p>I would like to avoid private APIs and the like, but I'm not sure why this usage is explicitly prohibited even when it seems to work fine.  Anyone know the reason?</p>
  
  <p>I've thought about putting the tab bar controller as the main controller, with each of the tabs containing separate navigation controllers.  The problem with this is that each nav controller needs to share a single root view controller (namely the "Accounts" table in <em>Tweetie</em>) -- this doesn't seem to work: pushing the table controller to a second nav controller seems to remove it from the first.  Not to mention all the book-keeping when selecting a different account would probably be a pain.</p>
  
  <p>How should I implement this the Right Way?</p>
  
  <p>[^1]: The tab bar controller needs to be subclassed so that the tab bar controller's navigation item at that level stays in sync with the selected tab's navigation item, and the individual tab's table controller's need to push their respective detail views to <code>self.tabBarController.navigationController</code> instead of <code>self.navigationController</code>.</p>