1

私はユニバーサルアプリケーションを持っています。このアプリケーションでは、紹介画像をスプラッシュ スクリーンとして設定します。iPhone の場合は別の画像をスプラッシュ スクリーンとして設定する必要があり、iPad の場合は別の画像を設定する必要があります。以下のコードを使用している場合、iphone では機能しますが、ipad では機能しません。私のコードは次のとおりです。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
   [self copyDatabaseIfNeeded];
   [window addSubview:navigationController.view];
   [window makeKeyAndVisible];

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    splashViewBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)];
    splashViewBg.image = [UIImage imageNamed:@"jamil.png"];
    //splashViewBg.contentMode = UIViewContentModeScaleAspectFill;
    [window addSubview:splashViewBg];

    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)];
    splashView.image = [UIImage imageNamed:@"jamil.png"];
    //splashView.contentMode = UIViewContentModeScaleAspectFill;
    splashView.alpha = 0.0f;
}
else
{
    splashViewBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    splashViewBg.image = [UIImage imageNamed:@"defualt.png"];
    //splashViewBg.contentMode = UIViewContentModeScaleAspectFill;
    [window addSubview:splashViewBg];

    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    splashView.image = [UIImage imageNamed:@"defualt.png"];
    //splashView.contentMode = UIViewContentModeScaleAspectFill;
    splashView.alpha = 0.0f;
}

[UIView beginAnimations:@"show" context:NULL];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
splashView.alpha = 1.0f;
[UIView commitAnimations];

[self performSelector:@selector(removeSplash) withObject:nil afterDelay:2.0];

[self performSelector:@selector(removeSplashBg) withObject:nil afterDelay:3.5];

return YES;
 }

 - (void) removeSplash {
   [UIView beginAnimations:@"hide" context:NULL];
   [UIView setAnimationDuration:1.0f];
   [UIView setAnimationCurve:UIViewAnimationCurveLinear];
   [UIView setAnimationDelegate:self];
   splashView.alpha = 0.0f;
  [UIView commitAnimations];
}

  - (void) removeSplashBg {
      [splashView removeFromSuperview];
      [splashViewBg removeFromSuperview];
}
4

1 に答える 1

2

これがあなたの質問に直接答えないことはわかっていますが、Apple のガイドラインでは、スプラッシュ スクリーンの画像を使用しないように明確に述べられています。これは、ユーザーにとって非常に貧弱で一貫性のないエクスペリエンスをもたらす可能性があるため、強くお勧めしません。アプリの読み込み中に画面を表示する必要がある場合は、コードを 1 行も書かずに表示できます。画像に Default.png と Default@2x.png という名前を付けるだけです。それらは自動的に読み込まれ、スプラッシュ スクリーンとして表示されます。「起動イメージ」のドキュメントを参照してください。

于 2012-06-01T17:47:33.077 に答える