gpt4 book ai didi

ios - 来自图像集的 iphone 动画

转载 作者:行者123 更新时间:2023-11-28 20:36:42 27 4
gpt4 key购买 nike

我有大约 5,000 张标记为 image_1 到 image_5000 的图像,我怎样才能创建一个循环播放每张图像然后重复的动画?这是一个 iPhone 应用程序,仅供我个人使用,非常感谢任何帮助。

这是我正在使用的代码,为什么它不起作用。

 //.h
@interface ViewController : UIViewController{
IBOutlet UIImageView *imageView;
int i;
}
@end

 - (void)viewDidLoad
{

i = 0;
[NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(loop)
userInfo:nil
repeats:YES];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)loop{
if (i<MAX_IMAGES) {

imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image_%d.bmp",i]];
NSLog(@"Image:%d",i);
i+=1;
if (i >= MAX_IMAGES) {
i = 1;
}
}
}

最佳答案

我会使用 NSTimer 一次将图像加载到 UIIMageView 中。这样您就可以控制图像更改之间的间隔并最大限度地减少内存使用。如果您需要示例代码,请告诉我。

关于ios - 来自图像集的 iphone 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10167889/

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