8

iOS 5.1を使用してアプリケーションを開発していますが、default.pngファイルで奇妙な動作が発生しています。

次のファイルをアプリケーションに追加しました。

Default.png-(iPhone)

Default@2x.ping-(iPhone Retina)

デフォルト-Portrait〜ipad.png-(iPad)

デフォルト-Portrait@2x~ipad.png-(iPad Retina)

アプリケーションが起動すると、その都度使用する正しいDefault.png画像が選択されているようです。ただし、私のAppDelegateには、アプリケーションの読み込みとアプリへの移行をスムーズにするためのシンプルなスプラッシュ画面があり、次のようなことを行っています。

UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,window.frame.size.width, window.frame.size.height)]; 
splashView.image = [UIImage imageNamed:@"Default"]; 
    
[window addSubview:splashView]; 
[window bringSubviewToFront:splashView]; 

ただし、[UIImage imageNamed:@"Default"]順番に各デバイスに正しいファイルが選択されるわけではなく、問題は-Portraitファイル名の一部にあると思います。

簡単な解決策として、私はこれを行いました:

if( ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ) {
    // Force the image used by ipads
    if( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0) {
       splashView.image = [UIImage imageNamed:@"Default-Portrait@2x~ipad"];
    }
    else {
        splashView.image = [UIImage imageNamed:@"Default-Portrait~ipad"];
    }
}
else
   splashView.image = [UIImage imageNamed:@"Default"];

これは私がこれを行うべき方法ですか?これはあなたにとって面白そうですか?

4

3 に答える 3

4

公式情報については、こちらをご覧ください:アプリ関連のリソース

起動イメージには、次の形式を使用します。

<basename><orientation_modifier><scale_modifier><device_modifier>.png

以下を使用する方が良いようです:

Default.png - (iPad)

Default@2x.png - (iPad Retina)

Default~iphone.png - (iPhone)

Default@2x~iphone.png -(iPhone Retina)

単純に使用した場合でも、これにより適切な画像が得られるはずです。

splashView.image = [UIImage imageNamed:@"Default"]; 
于 2012-04-12T12:14:56.640 に答える
2

ユニバーサル アプリの読み込みが完了したら、起動画面のコピーを表示してUIImageViewからフェード アウトし、起動とアプリの準備が整うまでの移行を緩やかにします。使用する画像を決定するために使用するコードは次のとおりです。

    // choose the correct launch image for orientation, device and scale
    NSMutableString *launchImageName = [[NSMutableString alloc] initWithString:@"Default"];
    BOOL isPad = ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad );
    if( isPad )
    {
        BOOL isLandscape = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]);
        NSString *imageOrientation = (isLandscape) ? @"Landscape" : @"Portrait";

        BOOL isRetina = ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0);
        NSString *scaleString = (isRetina) ? @"@2x" : @"";

        // Default-Landscape~ipad.png
        // Default-Landscape@2x~ipad.png
        // Default-Portrait~ipad.png
        // Default-Portrait@2x~ipad.png
        launchImageName = [NSMutableString stringWithFormat:@"%@-%@%@~ipad.png", launchImageName, imageOrientation, scaleString ];

    } else {

        if( CGRectGetHeight(self.view.frame) > 480.f)
        {
            // Default-568h.png
            launchImageName = [NSMutableString stringWithFormat:@"%@-568h.png", launchImageName];
        } else {
            // Default.png
            // Default@2x.png
            launchImageName = [NSMutableString stringWithFormat:@"%@.png", launchImageName];
        }
    }
    UIImage *launchImage = [UIImage imageNamed:launchImageName];
于 2013-04-25T20:30:28.237 に答える
0

http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html

アプリの起動 (デフォルト) 画像
<basename><usage_specific_modifiers><scale_modifier><device_modifier>.png

さまざまな方向の起動画像を提供する
<basename><orientation_modifier><scale_modifier><device_modifier>.png

カスタム URL スキームの起動イメージの提供
<basename>-<url_scheme><scale_modifier><device_modifier>.png
于 2012-05-13T19:04:56.667 に答える