构建代码后,我的手机上没有任何动画
但是代码看起来不错,我不知道如何解决,
我的图像是829 * 445,这会导致此问题吗?
有人可以帮我解决这个问题,我将非常感激,谢谢
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSArray *animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"1.jpg"],
[UIImage imageNamed:@"2.jpg"],
[UIImage imageNamed:@"3.jpg"],
[UIImage imageNamed:@"4.jpg"],nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,150,150)];
imageView.animationImages = animationImages ;
imageView.animationRepeatCount = 2;
imageView.animationDuration= 4.0;
[imageView startAnimating];
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self
selector:@selector(animationDone:)
userInfo:nil repeats:NO];
}
-(void)animationDone:(NSTimer*)inTimer
{
[inTimer invalidate];
inTimer = nil;
NSLog(@"animationDone ");
}
@end
您没有将imageView添加到ViewController视图中。
尝试[self.view addSubview:imageView];
在-viewDidLoad
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句