Can I use a UINavigationController as the detail view of a UISplitViewController?
Posted
by
B Sweigard
on Stack Overflow
See other posts from Stack Overflow
or by B Sweigard
Published on 2010-09-21T17:07:07Z
Indexed on
2011/01/16
14:53 UTC
Read the original article
Hit count: 145
ipad-splitview
I'm running into a problem with an iPad app where I would like to have UINavigationControllers in both of the views within a UISplitView. I've looked through other similar questions here, but most link to a tutorial online that doesn't completely solve the problem. Here's a 2-minute walkthrough to re-create the problem I'm having:
- Create a New Project in XCode, starting from the Split View-based Application template.
Add the following NSLog statement as the first line within the DetailViewController's willHideViewController method:
NSLog(@"toolbar: %@", toolbar);
If you run the application now, the log will show that the DetailViewController's toolbar is alive and well. Now...
- Open MainWindow.xib and expand the SplitViewController.
- Drag a Navigation Controller from the library on top of the DetailViewController.
- Expand the new Navigation Controller and change the class of the UIViewController within to a DetailViewController.
- Ctrl-drag from the SplitViewController to the DetailViewController and assign it as the delegate.
- Save MainWindow.xib and run the app again.
At this point, the detail view has a navigation bar and an empty toolbar. If you view the logs, you should find that the toolbar is null. Why is this? Am I missing some sort of connection in Interface Builder? Is the navigation bar the problem for some reason?
Unlike the tutorial at http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/, I would like to keep both the navigation bar and the toolbar (preferably with the toolbar at the top when in portrait and not visible when in landscape), so that I still have a functional "Back" button when the iPad is in portrait orientation.
Does anyone have any suggestions for fixing this problem? An example project with this sort of set-up would be ideal.
© Stack Overflow or respective owner