gpt4 book ai didi

ios - 动画 For 循环图像不显示

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

我从网上下载了动画篝火。我的图像序列是“*.png”,我无法让它工作。它一直循环到最后。它不显示图像。为什么我不能为这段代码设置动画?我做错了什么?

        UIImageView* campFireView = [[UIImageView alloc] initWithFrame:screenx.frame];
int j;
int i;

for (j = 1, i = 0; i < 28; i =1)
{
NSLog( @"%i.png", i);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];
}
// all frames will execute in 1.75 seconds
campFireView.animationDuration = .15;
// repeat the annimation forever
campFireView.animationRepeatCount = 1;
// start animatinganimationRepeatCount:1];

[campFireView startAnimating];

// add the animation view to the main window
[self.view addSubview:campFireView];
[campFireView release];

最佳答案

每次调用:

        campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];

您正在将 animationImages 设置为单项数组。您可能打算改为:

    NSMutableArray *animationImages = [NSMutableArray array];

for (i = 0; i < 28; i++)
{
[animationImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]]];
}

campfireView.animationImages = animationImages;

另外 - 我不知道你的 for 循环发生了什么,但我修复了它。

关于ios - 动画 For 循环图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12576693/

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