gpt4 book ai didi

objective-c - UIImageView isAnimating 是否在 4.0 SDK 中中断?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:27:37 26 4
gpt4 key购买 nike

以下代码在使用 iOS 3.x 构建时可以正常工作。现在使用 4.x 它不起作用。换句话说,我可以在同一台设备上运行两个相同的应用程序,一个是针对 per-4.x 版本构建的,另一个是针对 4.3 构建的,而在后者中,isAnimating 不会更改值,除非点击屏幕或方向改变。

这是相关代码。我从 Xcode 中基于 View 的模板开始。

- (void)viewDidLoad {
[super viewDidLoad];
iv.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"timer00.png"],
[UIImage imageNamed:@"timer01.png"],
[UIImage imageNamed:@"timer02.png"],
[UIImage imageNamed:@"timer03.png"],
[UIImage imageNamed:@"timer04.png"],
[UIImage imageNamed:@"timer05.png"],
[UIImage imageNamed:@"timer06.png"],
[UIImage imageNamed:@"timer07.png"],
[UIImage imageNamed:@"timer08.png"],
[UIImage imageNamed:@"timer09.png"],
[UIImage imageNamed:@"timer10.png"],
[UIImage imageNamed:@"timer11.png"],
[UIImage imageNamed:@"timer12.png"],
[UIImage imageNamed:@"timer13.png"],
[UIImage imageNamed:@"timer14.png"],
[UIImage imageNamed:@"timer15.png"],
[UIImage imageNamed:@"timer16.png"],
[UIImage imageNamed:@"timer17.png"],
[UIImage imageNamed:@"timer18.png"],
[UIImage imageNamed:@"timer19.png"],
[UIImage imageNamed:@"timer20.png"],
[UIImage imageNamed:@"timer21.png"],
[UIImage imageNamed:@"timer22.png"],
[UIImage imageNamed:@"timer23.png"],
[UIImage imageNamed:@"timer24.png"],
[UIImage imageNamed:@"timer25.png"],
[UIImage imageNamed:@"timer26.png"],
[UIImage imageNamed:@"timer27.png"],
[UIImage imageNamed:@"timer28.png"],
[UIImage imageNamed:@"timer29.png"],
[UIImage imageNamed:@"timer30.png"],
[UIImage imageNamed:@"timer31.png"],
[UIImage imageNamed:@"timer32.png"],
[UIImage imageNamed:@"timer33.png"],
[UIImage imageNamed:@"timer34.png"],
[UIImage imageNamed:@"timer35.png"],
[UIImage imageNamed:@"timer36.png"], nil];
iv.animationDuration = 5.0;
iv.animationRepeatCount = 1;
[iv startAnimating];
timer = [NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(periodicallyUpdateView)
userInfo:nil
repeats:YES];
}

- (void)periodicallyUpdateView {
if ([iv isAnimating]) {
NSLog(@"it is animating");
}
else {
NSLog(@"it is NOT animating");
}
}

还有其他人看到了吗?

最佳答案

如果您设置一个计时器,效率会高得多。您面临的问题可能不是 UIImageView 已损坏,而是 ImageView 需要很长时间才能加载动画。

我会推荐这样的东西。

NSTimer *imageTimer;

int animationCount;

- (void)startAnimation
{
imageTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(switchImage) userInfo:nil repeats:YES];
}

- (void)switchImage
{
NSString *imageName = [NSString stringWithFormat:@"timer%i" , animationCount];
UIImage *image = [UIImage imageNamed:imageName];
someImageView.image = image;
}

关于objective-c - UIImageView isAnimating 是否在 4.0 SDK 中中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6355037/

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