アプリがデータを読み込んでいる間、スプラッシュ スクリーンに GIF 画像を表示したいと考えています。
少なくとも約 3 秒または 4 秒間表示されるスプラッシュ画像があります。これが、ユーザーがアプリが読み込まれていると思うように、スプラッシュ画像の上に gif 画像のような読み込み中のテキストを表示したい理由です。
アプリがデータを読み込んでいる間、スプラッシュ スクリーンに GIF 画像を表示したいと考えています。
少なくとも約 3 秒または 4 秒間表示されるスプラッシュ画像があります。これが、ユーザーがアプリが読み込まれていると思うように、スプラッシュ画像の上に gif 画像のような読み込み中のテキストを表示したい理由です。
スプラッシュ画像にラベルを1つ追加しNSTimer
、以下のようにテキストを定期的に変更するだけです
splash = [[UIImageView alloc] initWithFrame:self.window.frame];
splash.image = [UIImage imageNamed:@"splash"];
[self.window addSubview:splash];
これは、スプラッシュ画面を表示するために使用するコードです。
NSTimer *loading = [[NSTimer alloc]init];
[loading performSelector:@selector(YOUR_SELECTOR) withObject:YOUR_LABEL afterDelay:0.3f];
ここで、YOUR_SELECTOR
はラベル テキストを設定するメソッドで、 はテキストを設定するラベルですYOUR_LABEL
。
EDIT
申し訳ありませんが、NSTimer
実際にはテキストの読み込みで activityindicator を使用しました...application:didFinishLaunchingWithOptions:
メソッドで
そのコードは
splash = [[UIImageView alloc] initWithFrame:self.window.frame];
splash.image = [UIImage imageNamed:@"splash"];
[self.window addSubview:splash];
hud = [[MBProgressHUD alloc]initWithView:splash];
[splash addSubview:hud];
hud.labelText = @"Loading...";
[hud show:YES];
[self performSelector:@selector(Load_FirstView) withObject:nil afterDelay:3];
[self.window makeKeyAndVisible];
Load_FirstView
方法は次のとおりです
-(void)Load_FirstView
{
[splash removeFromSuperview];
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
masterViewController.managedObjectContext = self.managedObjectContext;
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
}
Default.pngをスプラッシュ画像として使用している場合、それをアニメーション化する方法はありません。1つの方法は、アプリをすばやく起動して、データの読み込み中にアニメーションビューを表示することです。したがって、基本的に唯一の解決策は、Default.pngから離れて、代わりにアニメーション化できるカスタムビューを使用することです。
Default.png を使用して開始し、 (画面全体)と同じフレームを持つUIView
単一の を含むをロードします。Default.png をImageView の として設定し、必要に応じてコントロール ( など) を追加します。UIImageView
UIView
UIImage
UIActivityIndicatorView