When LinkedIn launched its simplified iPhone app last August, one of the defining features was its new navigation system. Today, we are releasing the code as an open source library, LIExposeController, under the Apache 2.0 License. With it, developers can easily create multiple, visually distinct areas in their apps for ease of flow for their users.
With this new experience, users can easily switch between different areas of the app in a visually pleasing way. We have gotten a lot of great feedback for this brand new navigation scheme, with a lot of our users calling it "easy to navigate" and "fun." We chose this model over a standard tab bar because we wanted something more visual and tactile, giving users more context for the different areas of the app.
Designing a container view controller
LIExposeController is a new container view controller class, much like UINavigationController or UITabBarController. Designing container controllers can get tricky when it comes to deciding how much functionality you want to offer. Doing too little can make it little more than a boring canvas, but doing too much can lead to code bloat and unnecessary re-implementation of core functionality offered by the OS. In the case of LIExposeController, we were faced with deciding how to maintain navigation stacks for each screen. Since we're context switching between different screens, does it make sense for us to maintain view controller hierarchies for each one in the app? We realized this would be over-engineering the problem. Instead, if a screen wants a view stack, it should just use a standard navigation controller.
Another decision we made was not to use the new container controller APIs in the iOS 5 SDK. This is so that we can continue support for iOS 4 devices. Of course, if you'd like to help out with that, we are accepting contributions!
- Add/Remove child controllers
- Multiple pages for screens
- Customizable layout, look & feel
- iPhone/iPad support
- iOS 4 support
One of the cool features of the library is that it extends UIViewController so that any standard controller can access the expose controller in which it is currently nested via a simple property. This was done via the objc_setAssociatedObject API, allowing us to add storage to UIViewController via a category. From Apple's own documentation: Using associative references, you can add storage to an object without modifying the class declaration. This may be useful if you do not have access to the source code for the class. This is very useful for creating libraries meant to integrate with other base classes, in UIKit or otherwise.
Integration is as simple as any other standard view controller in iOS:
The library comes with a sample application showing some of the basic functionality, including adding and deleting child controllers. And best of all, the library works for both iPhone and iPad. Check out the header file for more information on customization and delegate callbacks.
Try it out and Contribute!
Check out the code at https://github.com/linkedin/LIExposeController. Please try it out in your apps and send your feedback. We are accepting contributions, so go ahead, fork the code, and send us your pull requests!