尝试制作简单的 UIImageVIew 动画

Trying to make simple UIImageVIew animation

我正在尝试制作如此简单的 UIImageView 动画。我有 11 张 .png 类型的图像。动画只是兔子眨眼。我遇到数组问题:

UIImageView *animationView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2-123/2, self.view.bounds.size.height/2-278/2, 123, 278)];

    NSArray *imageNames = [NSArray arrayWithObjects:@"rabbit-1.png",@"rabbit-2.png",@"rabbit-3.png",@"rabbit-4.png",@"rabbit-5.png",@"rabbit-6.png",@"rabbit-7.png",@"rabbit-8.png",@"rabbit-9.png",@"rabbit-10.png",@"rabbit-11.png", nil];


    NSMutableArray *images = [[NSMutableArray alloc] init];

    for(int x =0; x==[imageNames count]; x++){
        UIImage *image = [UIImage imageNamed: [imageNames objectAtIndex:x]];
        [images addObject:image];
    }

    NSLog(@"image name array length is : %d",[images count]);



    animationView.animationImages=images;
    animationView.animationDuration=10;
    [self.view addSubview:animationView];
    [animationView startAnimating];

屏幕上没有显示任何内容,因为图像数组为空。不知道这是为什么。我在其中执行了 init 和 alloc,但是当我检查长度时,它返回为零。知道这里发生了什么吗?任何指针将不胜感激。谢谢

x == [imageNames count] 始终为 false,因此不会执行 for 循环。

换行

for(int x =0; x==[imageNames count]; x++)

for(int x = 0; x < [imageNames count]; x++)