splitviewcontroller で構成されるアプリケーション ウィンドウに画像ビューを追加しようとしています。これを行う理由は、スプラッシュ スクリーンのようにフェードアウトできるようにするためです。アプリケーションは iPad 用で、横向きモードでのみ動作します。起動イメージはスプラッシュ イメージと同じであるため、2 つの間でシームレスに遷移し、スプラッシュを手動でフェードアウトできます。ただし、起動画像からスプラッシュへの移行がシームレスで気付かれないように、起動画像と同じ向きでウィンドウのサブビューにスプラッシュを追加するのに問題があります。これが私がこれまでに持っているものです:
- (void)viewDidLoad
{
[super viewDidLoad];
UIWindow *window = [[UIApplication sharedApplication] delegate].window;
UIImageView *splash = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
splash.image = [UIImage imageNamed:@"Default-Landscape~ipad.png"];
[splash rotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
[window addSubview:splash];
}
@interface UIView (Orientation)
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation;
@end
@implementation UIView (Orientation)
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
CGFloat angle = 0.0;
switch (orientation) {
case UIInterfaceOrientationPortraitUpsideDown:
angle = M_PI;
break;
case UIInterfaceOrientationLandscapeLeft:
angle = - M_PI / 2.0f;
break;
case UIInterfaceOrientationLandscapeRight:
angle = M_PI / 2.0f;
break;
default: // As portrait
angle = 0.0;
break;
}
self.transform = CGAffineTransformMakeRotation(angle);
}
@end