gpt4 book ai didi

iphone - 设置了animationDidStop但没有被调用(iPhone应用程序编码)

转载 作者:行者123 更新时间:2023-12-03 16:53:29 25 4
gpt4 key购买 nike

#import "MyViewController.h"

@implementation MyViewController
@synthesize menuView, gameView, helpView, optionsView, gameButton, helpButton, optionsButton;

- (void) viewDidLoad {
[self setView:menuView];
}

- (IBAction)gotoGame {
[UIView beginAnimations:@"buttonSlide" context: nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];
gameButton.center = CGPointMake(104,1000);
[UIView commitAnimations];
}

- (IBAction)gotoHelp {
[self setView:helpView];
}

- (IBAction)gotoOptions {
[self setView:optionsView];
}

- (void)animationDidStop {
NSLog(@"why is this not working?");
[self setView:gameView];
}


@end

不确定什么会有帮助,所以我包含了整个 .m 文件。不管怎样,我是 iPhone 应用程序开发的新手,我正在努力完成我的动画。动画本身工作得很好,但是animationDidStop方法拒绝被调用..即使我按照文档中所示使用setAnimationDidStopSelector。我知道 View 更改有效,因为当我将其放在 gotoGame {} 中的动画之后时,它会切换,但这使得动画不会显示。

有人可以帮助我在动画停止后调用该方法,或者使用计时器在必要的时间后调用它吗? (我也尝试过这个方法,但没有成功)。

最佳答案

不仅需要调用[UIView setAnimationDelegate:self],而且如果动画的调用方法是静态的,则委托(delegate)也必须是静态的。大多数示例使用非静态方法来调用动画,因此如果您使用静态方法来制作动画,这可能会令人困惑(至少对我来说)。

关于iphone - 设置了animationDidStop但没有被调用(iPhone应用程序编码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1152045/

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