在我的Iphone App中,我使用以下代码在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];
答案 0 :(得分:4)
直到你告诉它开始动画才会开始。您需要添加一个命令来启动动画。我还清理了你的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"