いくつかの UIImageView オブジェクトをアニメーション化する .h、.m ページを設定しましたが、それらをアニメーション化できません。警告、エラーは発生していません。
何が悪いのか教えていただけますか?ティア
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *predictionLabel;
@property (strong, nonatomic) NSArray *predictionArray;
@property (strong, nonatomic) UIImageView *imageView;
- (void) makePrediction;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize predictionArray;
@synthesize imageView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage *image = [UIImage imageNamed:@"background_s4.png"];
self.imageView = [[UIImageView alloc]initWithImage:image];
[self.view insertSubview:self.imageView atIndex:0];
self.imageView.animationImages = [[NSArray alloc]initWithObjects:[UIImage imageNamed:@"cball00001.png"],
[UIImage imageNamed:@"cball00002.png"],
[UIImage imageNamed:@"cball00003.png"],
[UIImage imageNamed:@"cball00004.png"],
[UIImage imageNamed:@"cball00005.png"],
[UIImage imageNamed:@"cball00006.png"],
[UIImage imageNamed:@"cball00007.png"],
[UIImage imageNamed:@"cball00008.png"],
[UIImage imageNamed:@"cball00009.png"],
[UIImage imageNamed:@"cball00010.png"],
[UIImage imageNamed:@"cball00011.png"],
[UIImage imageNamed:@"cball00012.png"],
[UIImage imageNamed:@"cball00013.png"],
[UIImage imageNamed:@"cball00014.png"],
[UIImage imageNamed:@"cball00015.png"],
[UIImage imageNamed:@"cball00016.png"],
[UIImage imageNamed:@"cball00017.png"],
[UIImage imageNamed:@"cball00018.png"],
[UIImage imageNamed:@"cball00019.png"],
[UIImage imageNamed:@"cball00020.png"],
[UIImage imageNamed:@"cball00021.png"],
[UIImage imageNamed:@"cball00022.png"],
[UIImage imageNamed:@"cball00023.png"],
[UIImage imageNamed:@"cball00024.png"], nil];
self.imageView.animationDuration = 1.0;
self.imageView.animationRepeatCount = 1;
self.predictionArray = [[NSArray alloc]initWithObjects:@"It is certain",
@"All signs are YES",
@"The stars are not aligned",
@"My reply is no",
@"It is doubtful",
@"Better not tell you now",
@"Concentrate and ask again",
@"Unable to answer now", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) makePrediction
{
NSUInteger index = arc4random_uniform(self.predictionArray.count);
self.predictionLabel.text = [self.predictionArray objectAtIndex:index];
[self.imageView startAnimating];
}
- (BOOL) canBecomeFirstResponder
{
return YES;
}
- (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
self.predictionLabel.text = @"";
}
- (void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake){
[self makePrediction];
}
}
- (void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"motion cancelled");
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
self.predictionLabel.text = @"";
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self makePrediction];
}
@end