我有这段代码,试图循环播放一组简单的图片。在我的视图控制器的.h文件中只声明了一个UIImageView:
@property (strong, nonatomic) IBOutlet UIImageView *imageDisplay;
在我的.m文件的viewDidLoad方法中,添加以下内容:
NSMutableArray *imageView = [[NSMutableArray alloc] init];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim1.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim2.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim3.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim4.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim5.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim6.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim7.png"]]];
imageDisplay.animationImages = imageView;
imageDisplay.animationDuration = 0.25;
imageDisplay.animationRepeatCount = 50;
[imageDisplay startAnimating];
代码似乎在"imageDisplay.animationImages"这一行崩溃了,如果我创建UIImageView,创建它的getter和setter,并构建,那么它就没问题,直到我取消注释那一行。如果我取消注释,它会一直给我报错,直到我删除UIImageView并创建一个新的。不太确定发生了什么,请帮忙解决!