IOS NSArray arrayWithObjects

标签 ios arrays object block

我尝试使用 ArrayWithObjects 来创建滚动的运动。 我有一个问题,我的动画停止并在数字九处重复:/

这是我的代码:

background.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"background_wall2.png"], [UIImage imageNamed:@"background_wall3.png"], [UIImage imageNamed:@"background_wall4.png"], [UIImage imageNamed:@"background_wall5.png"], [UIImage imageNamed:@"background_wall6.png"], [UIImage imageNamed:@"background_wall7.png"], [UIImage imageNamed:@"background_wall8.png"], [UIImage imageNamed:@"background_wall9.png"], [UIImage imageNamed:@"background_wall10.png"], [UIImage imageNamed:@"background_wall11.png"], [UIImage imageNamed:@"background_wall12.png"], [UIImage imageNamed:@"background_wall13.png"], [UIImage imageNamed:@"background_wall14.png"], [UIImage imageNamed:@"background_wall15.png"], [UIImage imageNamed:@"background_wall16.png"], [UIImage imageNamed:@"background_wall17.png"], [UIImage imageNamed:@"background_wall18.png"], [UIImage imageNamed:@"background_wall19.png"], [UIImage imageNamed:@"background_wall20.png"], [UIImage imageNamed:@"background_wall21.png"], [UIImage imageNamed:@"background_wall22.png"], [UIImage imageNamed:@"background_wall23.png"], [UIImage imageNamed:@"background_wall24.png"], [UIImage imageNamed:@"background_wall.png"], nil];
[background setAnimationRepeatCount:0];
background.animationDuration = 0.3;
[background startAnimating];

你能帮帮我吗?

提前致谢

PS:抱歉我的英语不好

最佳答案

您的animationDuration 太小了。 您强制对象以比其最大可能性更快的速度呈现您的所有框架

来自 Apple 文档:

The time duration is measured in seconds. The default value of this property is equal to the number of images multiplied by 1/30th of a second. Thus, if you had 30 images, the value would be 1 second.

这意味着如果您有24 张图片,至少您必须将0.8 设置为持续时间。 (24/30)。

关于IOS NSArray arrayWithObjects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23788463/

相关文章:

ios - 如何使用 Storyboard在 viewController 中制作多个 View

iphone - 可以向下滑动UITabBarController吗?

ios - 模态视图 Controller 和 subview Controller 如何交互?

iphone - 如何从自定义模型对象数组中获取特定键的值

有人可以使我从 C 中的指针查找数组长度的方法无效吗

JavaScript - 等待所有 array.push() 完成后再返回函数

iOS合并pdf文件

ios - 从 json 数据值创建字典

c++ - 如何在 vector<vector<class *>> 中存储类对象并通过引用或值访问它们并将它们传递给函数

c++ - 创建移动赋值函数,不断获取 "pointer being freed was not allocated"