![](/img/trans.png)
[英]iPhone SDK: Download and Set UIImageView before first view controller is displayed
[英]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.