The following is a guest post by Dasmer Singh and originally appeared on his blog. Dasmer is currently in the iOS-000 class at The Flatiron School. You can follow him on Twitter here.
In class, some of us have been using a very cool CocoaPod – MMDrawerController. It’s very useful and similar UI has been used in Facebook, GroupMe, Twitter and a plethora of other apps as well.
The pod essentially creates drawers that open from the left and right of the view, and I think it’s a great place to put settings/navigation options on an already real-estate constrained screen.
I’ve posted an example on GitHub at the following link:
https://github.com/Dasmer/BlogDrawerPractice
Here I am using a category on MMDrawerController called MMDrawerController+Storyboard (MMDrawerController was made for XIBs or programmatically created View Controllers). In the storyboard I make the root view controller a MMDrawerController and then create 2 custom segue’s. One to a navigation controller and the other to a table view controller. I labeled the segue to the navigation controller “mm_center” and the segue to the table view controller “mm_left”.
This sounds hacky (and it is), but whenever you use MMDrawerController+Storyboard you MUST label your segues like this. The Cocoapod is amazing, but its not 100% perfect. Another issue with the pod is that when you turn on all breakpoints, if you don’t want a particular drawer (in my case I did not make a right drawer), the debugger stops at the exception when the MMDrawerController loads.
In my example I used the tableview to swap my center view controller. To do so, I had to be able to refer to my MMDrawerController (essentially my container ViewController kind of like a SplitViewController). To easily do that, I needed to import a UIViewController category ”UIViewController+MMDrawerController.h”. This comes in the pod and gives me access to the MMDrawerController by referring to self.mm_drawerController. Then I just reset the center view controller depending on which button was clicked.
Check out my repo at the link above. Below I posted links to the MMDrawerController Cocoapod and the Mhttps://itunes.apple.com/us/app/quickcontact-qrcode-scanner/id735849910 Cocoapod. They also have some extremely useful examples that discuss customization even further.
MMDrawerController:
https://github.com/mutualmobile/MMDrawerController
MMDrawerController+Storyboard:
My latest app QuickContact is now available in the App Store.
Here’s a link: https://itunes.apple.com/us/app/quickcontact-qrcode-scanner/id735849910
https://github.com/TomSwift/MMDrawerController-Storyboard
Chao!
Written byFLATIRON SCHOOL
Make yourself useful.