我创建了一个nsmutableArray,并为其添加图像。我也创建一个imageView,我想展示从数组中的图像,我试图使用animationImages,但我什么都没有发生,我该如何解决它? 这里是我的代码:来自阵列的图像
//Numbers images
UIImage *numberZero = [UIImage imageNamed:@"numberZero.png"];
UIImage *numberOne = [UIImage imageNamed:@"numberOne.png"];
UIImage *numberTwo = [UIImage imageNamed:@"numberTwo.png"];
UIImage *numberThree = [UIImage imageNamed:@"numberThree.png"];
UIImage *numberFour = [UIImage imageNamed:@"numberFour.png"];
UIImage *numberFive = [UIImage imageNamed:@"numberFive.png"];
UIImage *numberSix = [UIImage imageNamed:@"numberSix.png"];
UIImage *numberSeven = [UIImage imageNamed:@"numberSeven.png"];
UIImage *numberEight = [UIImage imageNamed:@"numberEight.png"];
UIImage *numberNine = [UIImage imageNamed:@"numberNine.png"];
//add numbers uiimage to numbersArray
numbersArray = [NSMutableArray arrayWithObjects:numberZero, numberOne, numberTwo, numberThree, numberFour, numberFive, numberSix, numberSeven, numberEight, numberNine, nil];
imgview1 = [[UIImageView alloc] init];
imgview1.animationImages = numbersArray;
imgview1.animationDuration = 2;
imgview1.animationRepeatCount=0;
[imgview1 startAnimating];
[imgview1 stopAnimating];
谢谢!
我创建一个IBOutlet,并连接到我的ImageView,当我使用此代码:[imgview1 setImage:numberSix]。在我的屏幕上初始化numberArray之前它的视图数字6。 – cnaaniomer
我也检查是否我的图像插入到我的数组通过:[imgview1 setImage:[numbersArray objectAtIndex:5]];它的工作。这意味着问题出在我的anumationImages上。 – cnaaniomer
1.确保数组中没有图像为零,如果没有任何图像出现,则没有图像。 2.由于您使用IB连接,因此请勿分配它!或者您将过度编写IB连接。 – Joe