The Sliding Split View Controller is a tiny class implementing sliding pane navigation sported by the Facebook, Path, and Sparrow apps on iOS. (Many other apps have them, but these are the ones on my iPhone right now.) The controller is extremely simple — it holds a masterViewController and a detailViewController. By default, the Master view controller is hidden, but you can show it, and animate the process optionally, like the many methods:
- (void) setShowingMasterViewController:(BOOL)showingMasterViewController animated:(BOOL)animate completion:(void(^)(BOOL didFinish))callback;
- (void) setMasterViewController:(UIViewController *)toMasterVC animated:(BOOL)animate completion:(void(^)(BOOL didFinish))callback;
- (void) setDetailViewController:(UIViewController *)toDetailVC animated:(BOOL)animate completion:(void(^)(BOOL didFinish))callback;
The reason behind copious callbacks is that manually tracking every single possible animations is tedious or impossible without hacks — already so with the Map View — and stacking multiple animations usually won’t work well in a serious setup. So, I’ve got a rule of thumb that all the methods which could animate should accept a callback block.
A particular project of mine uses this controller, and I have been getting some interesting feedback regarding its interaction with different iOS controls (the Table View, the Map View, miscellany controls like Buttons and Sliders, and other gesture recognizers in custom views).
Deep down, it uses View Controller Containment introduced in iOS 5, and the whole thing was a blast to build both in terms of development speed and feeling. New code feels good.
Going forward, these issues are on my mind regarding the project:
- Minor UX issues like the Master view controller showing through when the Detail pane is dragged leftwards needs to be resolved thru more application-centric work.
- It needs hysterisis and bounceback to feel more realistic.
- It needs some better API regarding custom presenting / dismissal animations.
- It probably needs a way to extend support for a second Master view controller shown on the right.
- The sample app probably needs to be done, in terms that supporting a reference implementation for a common Master–Detail navigation structure might be utterly needed for new people to utilize this class efficiently.
I’m confident that these problems are either already solved, or trivial (though tedious) to implement. We’ll see where it goes, and please drop me a line if you plan on using it in your next project.