Over the recent break between fall and spring semesters I worked to build my first GUI for the iPad. The app I am working on (Clyde’s Garden Planner) is a universal app which needs to support all iOS devices. I was following the same basic layout of the iPhone GUI which uses a UITabBarController as the root view controller. However, difficulty arose when I set some of the tab bar subviews to instances of UISplitViewController.
I started researching the problem and found that having a UISplitViewController was, at least at one time, prohibited by Apple. I also found some people saying that those statements had been removed from the Apple documentation. I looked and couldn’t find anything prohibiting this behavior in current Apple documentation so I am inclined to say it is no longer prohibited. However, just because it may not be explicitly prohibited anymore doesn’t mean it works…
I would get several layout issues when switching to one of the split views after a rotation had occurred on a non-split view tab.
I found some solutions people had come up with which involved subclassing UISplitViewController and subscribing to event notifications or subclassing UIViewController and mimicking the functionality of the split view controller. I tried implementing one of these in my project but I still had some issues (probably due to the iOS6 layout manager).
I knew the problems occurred because the split view controllers were not receiving certain events that they would be if they were visible so I started playing around with forwarding events, etc and eventually came up with a solution.
My solution is shown in the following two Gists from GitHub.
Basically I first subclass UITabViewController and inside I forward rotation events to any child view controllers that are of the UISplitViewController kind. Then I subclassed UISplitViewController and forced one of the delegate methods to be called (splitViewController:willShowViewController:invalidatingBarButtonItem:). I’m not sure why I still had to force that delegate method to be called but I believe it must have something to do with the view not currently being visible. Subclassing both these objects is explicitly allowed by Apple as of iOS6.
You can find these objects in my GitHub project DCToolKit. If anyone has any insight or has solved this a better way in iOS6 please feel free to comment or better yet fork my project and submit a pull request.