0

这是我到目前为止所拥有的:

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;

-(void)animate
{
    [UIView animateWithDuration:1 animations:^{
        splashImage.frame = CGRectMake(0,480,320,480);
    }];
    [UIView commitAnimations];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    splashImage = [[UIImageView alloc] initWithImage:[UIImage
                                                      imageNamed:@"carolinaWolf.png"]];
    splashImage.frame = CGRectMake(0, 0, 320, 480);
    [self.tabBarController.view addSubview:splashImage];
    [self animate];
    return YES;
}

我在情节提要中的初始视图是 TabBarController。我想要发生的是:在我将新内容加载到应用程序后,我想启动屏幕以在屏幕上向下和关闭动画。这在我开始使用情节提要之前有效,为什么现在不起作用?

我的 AppDelegate.h 看起来像这样:

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@end
UIImageView *splashImage;
4

2 回答 2

1

您可以像这样直接添加您splashImageself.window.rootViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIImage *splashImage = [UIImage autoAdjustImageNamed:@"Default.png"];
    UIImageView *splashImageView = [[UIImageView alloc] initWithImage:splashImage];
    [self.window.rootViewController.view addSubview:splashImageView];
    [self.window.rootViewController.view bringSubviewToFront:splashImageView];
    [UIView animateWithDuration:1.5f
                          delay:2.0f
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         splashImageView.alpha = .0f;
                         CGFloat x = -60.0f;
                         CGFloat y = -120.0f;
                         splashImageView.frame = CGRectMake(x,
                                                            y,
                                                            splashImageView.frame.size.width-2*x,
                                                            splashImageView.frame.size.height-2*y);
                     } completion:^(BOOL finished){
                         if (finished) {
                             [splashImageView removeFromSuperview];
                         }
                     }];

    return YES;
}
于 2013-04-19T03:07:33.913 回答
0

这就是我淡出启动画面的方式:

#pragma mark Fading Default.png 动画

@interface FadeDefault : UIViewController
@end
@implementation FadeDefault

- (void)viewDidLoad 
{
    [super viewDidLoad];

    UIImageView *fader = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default@2x.png"]];
    [fader setFrame:CGRectMake(0,0,320,480)];

    /*if ( IDIOM == IPAD ) /* Optional */
    {
        fader = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default-Portrait~ipad.png"]];  
        [fader setFrame:CGRectMake(0,0,768,1024)];
    }else
      {
        fader = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default@2x.png"]];
        [fader setFrame:CGRectMake(0,0,320,480)];
    }*/
    self.view = fader;
    [fader release];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.0];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(imageDidFadeOut:finished:context:)];
    self.view.alpha = 0.0;
    [UIView commitAnimations];
}
- (void)imageDidFadeOut:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{
    [self.view removeFromSuperview];
}
@end

#pragma mark - 应用程序生命周期

请记住,这是一个示例,尽管我实际使用的代码并且我知道有效,但您需要保留其他didFinishLaunchingWithOptions代码。只需将fader代码添加到现有代码中即可。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    /*  custom fading Default.png animation  */
    FadeDefault * fader = [[FadeDefault alloc] init];

    [window addSubview:navigationController.view];

    [window addSubview:fader.view];
    [fader release];

    [window makeKeyAndVisible];

    return YES;
}
于 2012-07-06T02:06:45.893 回答