#If you're using storyboards...
If you're targeting OS X 10.10 and later (and using storyboards), you can use a custom NSStoryboardSegue to transition between view controllers. GRPushSegue implements this.
Simple navigation controller, provides navigation to a stack of view controllers.
Note: your view controllers must subclass GRViewController
I recommend setting everything up in IB.
Here's what you must hook up:
The view where the navigation controller will put it's contents
The view controller added to the stack immediately after the navigation controller awakes, it's the first view controller
An outlet to the button to use as the "back" button, this can be any subclass of NSControl (preferably NSButton or NSSegmentedControl).
###Pushing a view controller
// inside a subclass of GRViewController [self.navigationController pushViewController:self.myOtherVC animated:YES]
###Popping the front view controller
// inside a subclass of GRViewController [self.navigationController popViewControllerAnimated:YES]
GRViewController is an abstract class, subclassed from NSViewController, which can be used inside GRNavigationControllers.
You use It just like a regular NSViewController but there are some additional methods you can override to control it's behavior on the navigation stack.
###Using a custom rewind transition
If you want your view controller to be popped using a specific transition, you can set It's rewindTransition property to a custom CATransition.
// inside a subclass of GRViewController // create and set the custom transition CATransition *rewind = [CATransition animation]; rewind.type = kCATransitionFade; self.rewindTransition = rewind; // pop [self.navigationController popViewControllerAnimated:YES];
There are 5 methods you can override to work with the navigation:
Sent right after awakeFromNib
Sent when the view is about to appear
Sent when the view has just appeared
Sent when the view is about to disappear
Sent when the view has just disappeared
Note: viewWillAppear and viewWillDisappear occur inside a CATransaction, therefore any animations will be grouped with the navigation animation.
##Sample App: Countries
See the included sample app "Countries" for a complete example of how to use the navigation controller.
The superview of the navigation controller's view must be layer backed, which means anything inside the navigation must work in layer backed mode.
You can contribute with code, just send me a pull request, or open an issue for any bug/enhancement.
Disclaimer: sending a pull request does not mean I will accept It, if I don't accept your pull request It doesn't mean I don't love you ;)