MBSpacialViewController lets you create an arbitrarily complex map of view controllers in 2D space.
Why would you want to do that? Because it's cool. That's why.
Using gestures, you can navigate up, down, left, and right from any view controller.
A map is automatically generated and displayed in the bottom left corner.
You can see a live demo in the AppStore in Dicto: https://itunes.apple.com/us/app/dicto/id591603333?mt=8
Usage is best explained by checking out the easy to follow sample code. Basically:
1. Create a master view controller which inherits from
2. Set the master's root property to any view controller (must inherit from
3. Set the root's
left/right/upper/lower viewController property. You can do this recursively to create a complex map of view controllers in 2D space: For example:
self.leftViewController = [some subclass of MBSpacialChildViewController]; self.upperViewController = […]; self.upperViewController.leftViewController.lowerViewController = […];
Navigating through view controllers is done via gestures, but can also be done programatically:
[self moveInDirection:MBDirectionLeft animated:YES]; where
self is a subclass of
If you want a view controller to be deallocated and removed from the heirarchy after it disappears, you can make it a modal:
MBSpacialChildViewController *controller = […] controller.isModal = YES; controller.modalPresentingViewController = self; self.rightViewController = controller; [self moveInDirection:MBDirectionRight animated:YES];
By default, navigation is done via 1 finger pan. If you'd like to require 2 fingers (to avoid clash with scroll views and table views), you can do:
self.panGesture.minNumberTouchesLeft = 2;
This will also update the map to display 2 lines instead of 1 to indicate a two-finger swipe requirement.
(Note: Minimal testing was done on this feature)
MBSpacialViewController doesn't use UIKit view callbacks such as viewDidAppear or viewWillAppear. Instead, we use:
-(void)spacialViewDidLoad; -(void)spacialViewWillAppear; -(void)spacialViewDidAppear; -(void)spacialViewWillDisappear; -(void)spacialViewDidDisappear;
Any view controller that is part of the view heirarchy must inherit from
MBSpacialViewController is available under the MIT license.