Matt Cooper
Matt Cooper

Reputation: 2062

NSViewAnimation for NSTableView Not Working on Mavericks

I have a laptop that runs OSX 10.8, which is what I have been using to develop an app. I went to test the app on my desktop -- which runs 10.9 -- today and found that everything works the same except one animation.

I have an intro screen and want that to fade out and fade in the next screen; however, the second screen that fades in has an NSTableView on it. On 10.8 the table view fades in correctly with the rest of the view it's in, but in 10.9 when the animation is triggered, the table view appears fully instantly, not animating with the rest of the view.

I've created a small example and attached videos of it running below as well as the code. In the example, the view should be fading from a pure blue view to a view with an NSTableView and a red background. For the sake of simplicity, I just have the animation starting when the app launches, which is why the table view is fully visible upon start of the Mavericks run.

Video of Bug

AppDelegate.m:

#import "AppDelegate.h"
#import "SecondViewController.h"
#import "BlueBGView.h"

@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    BlueBGView *blueView = [[BlueBGView alloc]initWithFrame:self.window.frame];
    SecondViewController *SVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];

    [self.window.contentView addSubview: blueView];
    blueView.frame = ((NSView*) self.window.contentView).bounds;

    [self.window.contentView addSubview: SVC.view];

    //Animate
    NSMutableDictionary *blueViewDict, *SVCDict;

    blueViewDict = [NSMutableDictionary dictionaryWithCapacity:2];
    [blueViewDict setObject:blueView forKey:NSViewAnimationTargetKey];
    [blueViewDict setObject:NSViewAnimationFadeOutEffect
                        forKey:NSViewAnimationEffectKey];

    SVCDict = [NSMutableDictionary dictionaryWithCapacity:2];
    [SVCDict setObject:SVC.view forKey:NSViewAnimationTargetKey];
    [SVCDict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];

    NSViewAnimation *animation = [[NSViewAnimation alloc]initWithViewAnimations:[NSArray arrayWithObjects:blueViewDict, SVCDict, nil]];
    [animation setDuration: 5];
    [animation setAnimationCurve:NSAnimationEaseIn];

    [animation startAnimation];
}
@end

Upvotes: 2

Views: 185

Answers (0)

Related Questions