1

アプリのスプラッシュ画面に UIActivityIndi​​cator を追加することは可能ですか?

私はdelegate.mファイルで次のコードを使用していますが、うまくいきません..

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [NSThread sleepForTimeInterval:5.0];  //for running splash screen more time
     UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
   [self.view addSubview:spinner];
    [spinner performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1.0];


    return YES;
}

私を助けてください

4

2 に答える 2

3

アプリのスプラッシュ スクリーンは、静的な単なる png ファイルです。スピナーやアニメーションのようなものを追加することはできません。ただし、スプラッシュ スクリーンの読み込みが完了したら、同じスプラッシュ スクリーンを持つビューを表示し、プログラムまたはインターフェイス ビルダーを使用してスピナーをビューに追加できます。基本的に、ユーザーの観点からは、違いはわかりません。

私は以前にこの手法を使用したことがあり、非常にうまく機能します。

ちなみに、スリープ コールはアプリケーションを一時的にフリーズさせます。OSが応答しないためにアプリを終了しないように、NSTimerを使用することをお勧めします。

于 2013-08-02T06:01:50.277 に答える
2

これを試して...

UIImageView *splashView; // appDelegate.h で宣言

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    splashView = [[UIImageView alloc]initWithFrame:self.window.bounds];
    if (self.window.bounds.size.height > 480)
    {
        splashView.image = [UIImage imageNamed:@"Default-568h@2x.png"];
    }
    else
    {
        splashView.image = [UIImage imageNamed:@"Default.png"];
    }

    [self.window addSubview:splashView];

   // Add your spinner here.

    return YES;
}

私が助けてくれることを願っています。

于 2013-08-02T06:49:54.703 に答える