カスタムスプラッシュ画面を使用したいので、アプリデリゲートでこれを実行しています
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
homeNavigationController = [[UINavigationController alloc] init];
homeNavigationController.navigationBarHidden = NO;
[homeNavigationController pushViewController:viewController animated:NO];
// Add the view controller's view to the window and display.
[window addSubview:homeNavigationController.view];
[window makeKeyAndVisible];
[self animateSplash];
return YES;
}
- (void)animateSplash {
CGRect cgRect = [[UIScreen mainScreen] bounds];
CGSize cgSize = cgRect.size;
// set default portrait for now, will be updated if necessary
NSString *imageName = @"splash_screen.png";
CGRect imageFrame = CGRectMake( 0, 0, cgSize.width, cgSize.height );
imageStage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
imageStage.frame = imageFrame;
[window addSubview:imageStage];
[window bringSubviewToFront:imageStage];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:2];
[UIView setAnimationDuration:3.0f];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
imageStage.alpha = 0.0f;
[UIView commitAnimations];
}
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
// remove and clean up splash image view
[imageStage removeFromSuperview];
[imageStage release];
imageStage = nil;
}
これは問題なく動作しますが、アプリが横向き(ホームボタン右)モードで起動するため、スプラッシュ画像の向きが正しく設定されていません。