Iphone 无法在didFinishLaunchingWithOptions中制作动画

Iphone 无法在didFinishLaunchingWithOptions中制作动画,iphone,objective-c,ios,xcode,uiimageview,Iphone,Objective C,Ios,Xcode,Uiimageview,我在didfishlaunchingwithoptions中有此代码: self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UIViewController *myViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]]; self.

我在
didfishlaunchingwithoptions
中有此代码:

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;
我做错了什么?
提前谢谢

在视图控制器中:

//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

将代码放入ViewDidLoad中

m

animation.animationImages=[NSArray arrayWithObjects:

[UIImageNamed:@“chicken1.tiff”]

[UIImageNamed:@“chicken2.tiff”]

[UIImageName:@“chicken3.tiff”],无]

[animationsetAnimationRepeatCount:0]

animation.animationDuration=1

[动画开始动画]

h


IBUIImageView*动画

您需要显示图像,我不确定您的图像视图代码在哪里,但如果它在视图控制器中,您应该有
addSubview
。@Dustin您是如何做到的?最重要的是,我以后如何删除它?但我每次应用程序启动时只显示一次如何?你知道如何运行这个东西吗?在某个地方存储一个布尔变量(比如app delegate),它指示动画是否已经显示,并在运行代码之前检查它。我尝试了这个,但它不起作用。我不知道为什么。把它放在我能放的任何地方,但仍然没有任何代码可以工作;尝试记录
[self.view子视图]
并查看是否显示imgView。如果某个视图被取消分配,然后稍后加载,则每次应用程序启动时可能会调用该视图不止一次。我以前就这样使用过。