I've used the following method with limited success (still looking for a better solution, or to eliminate some visual hiccups that occur).
Create a subclass of NSTabViewController
, being sure to set the custom class of the tab view controller in your storyboard to your newly created subclass.
By default, NSTabViewController
makes the following three calls when switching from one tab view item to another:
tabView:willSelectTabViewItem:
transitionFromViewController:toViewController:options:completionHandler:
tabView:didSelectTabViewItem:
In your custom subclass, you can override transitionFromViewController:toViewController:options:completionHandler:
to implement your own switching method.
I've used something like the following:
- (void)transitionFromViewController:(NSViewController *)fromViewController
toViewController:(NSViewController *)toViewController
options:(NSViewControllerTransitionOptions)options
completionHandler:(void (^)(void))completion {
NSWindow *window = self.view.window;
NSView *superview = fromViewController.view.superview;
[superview replaceSubview:fromViewController.view with:blankView()];
[window resizeToSize:toViewController.view.frame.size]; // category defined elsewhere
[superview replaceSubview:blankView() with:toViewController.view];
window.title = toViewController.title;
}