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

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 - アプリケーションのライフサイクル

これは一例であることを覚えておいてください。私が実際に使用し、機能することを知っているコードですが、他のコードをそのままにしておく必要がありますdidFinishLaunchingWithOptionsfaderコードを既存のコードに追加するだけです。

- (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 に答える