2012-08-17 58 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