0

我有这个代码didFinishLaunchingWithOptions

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

UIViewController *myViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];

self.window.rootViewController = myViewController;

[self.window makeKeyAndVisible];

我想让 UIImageView 出现、播放动画并在那之后消失。我将此代码添加到我现有的代码中,但没有发生任何事情:

UIImageView *imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    NSArray *animationFrames = [[NSArray alloc]initWithObjects:blablahblah, nil];

    imgView.animationImages = animationFrames;
    imgView.animationDuration = 1.5;
    imgView.animationRepeatCount = 1;

我在这里做错了什么?提前致谢!

4

2 回答 2

1

将您的代码放入您的 ViewDidLoad。

.m

animation.animationImages = [NSArray arrayWithObjects:

[UIImageimageNamed:@"chicken1.tiff"],

[UIImageimageNamed:@"chicken2.tiff"],

[UIImageimageNamed:@"chicken3.tiff"],nil];

[动画集动画重复计数:0];

动画.animationDuration = 1;

[动画开始动画];

。H

IBOutlet UIImageView *动画;

于 2012-08-08T17:43:33.163 回答
0

在视图控制器中:

//use the view controller's frame
UIImageView *imgView = [[UIImageView alloc] initWithFrame:self.view.frame]];

NSArray *animationFrames = [[NSArray alloc]initWithObjects:blablahblah, nil];

imgView.animationImages = animationFrames;
imgView.animationDuration = 1.5;
imgView.animationRepeatCount = 1;

[self.view addSubview:imgView]; //Add the image view to the current view

去除:

[imgView removeFromSuperview]; //call when animation is done
于 2012-08-08T16:36:59.360 回答