gpt4 book ai didi

objective-c - AnimationDidStop 未被调用

转载 作者:行者123 更新时间:2023-11-29 04:43:41 26 4
gpt4 key购买 nike

由于某种原因,我的animationDidStop方法没有被调用,最初我认为这是因为未设置委托(delegate),但经过补救后我仍然遇到同样的问题。有任何想法吗?预先感谢:)

- (void)hideInterfaceButtonClicked : (id) sender
{

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];

[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.5];

// Move to the right
CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(454,288);
// Scale
CGAffineTransform scale = CGAffineTransformMakeScale(0.20,0.20);

// Apply them to the view
self.transform = CGAffineTransformConcat(scale, translateInterface);

self.alpha = 0.0;

[UIView commitAnimations];

}

- (void)animationDidStop {

NSLog(@"Animation Has Stopped");
[[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInteraceViewNeeded" object:self]; //after MoveView finishes

}

最佳答案

您可以通过使用the new (iOS4+) block syntax来实现您想要的:

[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationCurveEaseIn
animations:^{
// Move to the right
CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(454,288);
// Scale
CGAffineTransform scale = CGAffineTransformMakeScale(0.20,0.20);

// Apply them to the view
self.transform = CGAffineTransformConcat(scale, translateInterface);

self.alpha = 0.0;
} completion:^(BOOL finished) {
NSLog(@"Animation Has Stopped");
[[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInteraceViewNeeded" object:self]; //after MoveView finishes
}];

关于objective-c - AnimationDidStop 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9978915/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com