5

I have an NSTabViewController which have attached 6 tabs (NSViewControllers). From IB I have the possibility to chose from a few predefined transitions, but I don't like any of them. So my question is : How can I make my own transition?

PS: I'm use StoryBoards on my project.

NSGod
  • 22,699
  • 3
  • 58
  • 66
C-Viorel
  • 1,801
  • 3
  • 22
  • 41

1 Answers1

0

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:

  1. tabView:willSelectTabViewItem:

  2. transitionFromViewController:toViewController:options:completionHandler:

  3. 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;
}
NSGod
  • 22,699
  • 3
  • 58
  • 66