2012-08-17 56 views
0

我的動畫滾動NSScrollView,用這段代碼:CAAnimation animationDidStop不調用NSAnimationContext

[NSAnimationContext beginGrouping]; 
    NSClipView* clipView = [self contentView]; 
    NSPoint newOrigin = [clipView bounds].origin; 
    newOrigin.x = page*kGalleryWidth; 
    [[clipView animator] setBoundsOrigin:newOrigin]; 
    [NSAnimationContext endGrouping]; 

現在,我試圖讓觸發動畫結束事件。 我讀過一段代碼,使用CAAnimation,我很容易實現它,但我不能。

我已經試過這下面的代碼:

CAAnimation *moveAnimation = [[self.contentView animationForKey:@"frameOrigin"] copy]; 
moveAnimation.delegate = self; 
[self.contentView setAnimations:[NSDictionary dictionaryWithObject:moveAnimation forKey:@"frameOrigin"]]; 
  • (無效)animationDidStop:(CAAnimation *)動畫完成:(BOOL)標誌{

    的NSLog(@ 「住手!」 );

}

是否有人能幫助我嗎?

謝謝!

回答

0
[UIView beginAnimations:@"goback" context:nil]; 
[UIView setAnimationDuration:0.3f]; 
[UIView setAnimationBeginsFromCurrentState:NO]; 
dragOperation.draggable.center =dragOperation.initialPoint; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; 
UIView commitAnimations]; 




-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
    [self.layer removeAnimationForKey:@"goback"]; 
} 
+0

對不起,我忘了意見,就是我工作的OSX,iOS的不。 – user1573607 2012-08-20 05:11:01