繁体   English   中英

视图中不显示UIImageView动画

[英]UIImageView animation is not displayed on view

在我的Iphone应用程序中,我在viewDidLoad()方法中使用以下代码来处理这3个图像的动画,并使用左变换来加载此ViewController。 但是这些imageView不会显示在视图上。

NSArray *newArray = [[NSArray alloc]initWithObjects:[UIImage imageNamed:@"search1.png"],
                                                    [UIImage imageNamed:@"search2.png"],
                                                    [UIImage imageNamed:@"seach3.png"],
                                                    nil];
UIImageView *imageView = [UIImageView alloc];
[imageView initWithFrame:CGRectMake(240, 60, 60, 30)];
imageView.animationImages = newArray;
imageView.animationDuration = 0.25;
imageView.animationRepeatCount = 3;
[self.view addSubview:imageView];

直到你告诉它开始动画才会开始。 您需要添加一个命令来启动动画。 我还清理了你的alloc / init,并添加了一个命令,使图像视图在不动画时仍然显示。 设置动画不会使图像显示。 image属性用于静止图像, animationImages属性用于UIImageView的动画图像。

 UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(240, 60, 60, 30)];
imageView.image = [UIImage imageNamed:@"search3.png"]; //This will be the image that is visible when it is NOT animating.


imageView.animationImages = newArray;
imageView.animationDuration = 0.25;
imageView.animationRepeatCount = 3;
[imageView startAnimating]; //This will make the animation start

[self.view addSubview:imageView];

最后,你的第三张图片缺少r。 我想你想要@"search.png"而不是@"seach.png"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM