I. Static Image settings
IOS devices have three different resolutions: iPhone 320x480, iPhone 4 640x960, and iPad 768x1024. In the past, you only needed to prepare a Default.png startup screen (image), but now it is much more complicated. The following is a summary of CocoaChina members.
If a program supports both iPhone and iPad, it must contain the following images:
Default-Portrait.png iPad dedicated vertical boot screen 768x1024 or 768x1004
Default-Landscape.png iPad dedicated landscape boot screen 1024x768 or 1024x748
Default-PortraitUpsideDown.png iPad dedicated vertical boot screen (Home button on screen), can omit 768x1024 or 768x1004
Horizontal boot screen for Default-LandscapeLeft.png iPad, omitted 1024x768 or 1024x748
Horizontal boot screen for Default-LandscapeRight.png iPad, omitted 1024x768 or 1024x748
Default.png iphone boot image. If you do not have a few ipad boot images, you can also use 320ult.png (not recommended) 320x8.0 or 320x460 at the runtime of ipad.
Default@2x.png iPhone4 boot pictures 640x960 or 640x920
To use the above boot screen on the iPad, you also need to add the key: UISupportedInterfaceOrientations in info. plist. In addition, the value UIInterfaceOrientationPortrait, UIInterfacOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, and UIInterfaceOrientationLandscapeRight are added.
2. Set the duration of the Static Image
You can use the following methods in-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions:
1. sleep (3 );
2. [NSThread sleepForTimeInterval: 5.0];
3. [selfperformSelector: @ selector (startupview) withObject: nilafterDelay: 3];
3. Set the startup Animation
Load the animation controller in appDelegate, load the homepage controller in the animation-enabled controller, and set fade in and fade out through transparency.
AppDelegate. h
#import <UIKit/UIKit.h>#import "Startupscreen.h"@interface AppDelegate : UIResponder <UIApplicationDelegate> { Startupscreen *startupscreen;}@property (strong, nonatomic) UIWindow *window;@property (nonatomic, retain) Startupscreen *startupscreen;@end
AppDelegate. m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ NSLog(@"didFinishLaunchingWithOptions"); self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; startupscreen = [[Startupscreen alloc] initWithNibName:@"Startupscreen" bundle:nil]; [self.window addSubview:startupscreen.view]; [self.window makeKeyAndVisible]; return YES;}
Startupscreen. h
#import <UIKit/UIKit.h>#import "ViewController.h"@interface Startupscreen : UIViewController{ NSTimer *timer; UIImageView *splashImageView; UINavigationController *nav; ViewController *myviewcontroller;}@property (nonatomic,retain) NSTimer *timer;@property (nonatomic,retain) UIImageView *splashImageView;@property (nonatomic,retain) UINavigationController *nav;@property (nonatomic,retain) ViewController *myviewcontroller;@end
Startupscreen. m
#import "Startupscreen.h"#import "ViewController.h"@interface Startupscreen ()@end@implementation Startupscreen@synthesize timer;@synthesize splashImageView;@synthesize nav;@synthesize myviewcontroller;int flag;NSTimer *timer;- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self;}- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view from its nib. CGRect appFrame = [[UIScreen mainScreen] applicationFrame]; UIView *view = [[UIView alloc] initWithFrame:appFrame]; view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; self.view = view; [view release]; flag = 0; splashImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"c618Default1.png"]]; splashImageView.frame = CGRectMake(0, 0, 768, 1004); [self.view addSubview:splashImageView]; timer = [NSTimer scheduledTimerWithTimeInterval:0.6 target:self selector:@selector(addLabel) userInfo:nil repeats:YES]; myviewcontroller = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; myviewcontroller.view.alpha = 0.0; //[self.view addSubview:myviewcontroller.view]; nav = [[UINavigationController alloc] init]; [nav pushViewController:myviewcontroller animated:NO]; [self.view addSubview:nav.view]; timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(fadeScreen) userInfo:nil repeats:NO]; }- (void)addLabel{ flag++; if (flag <=5) { UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(200+50*flag,600,40, 40)]; label1.text = @"123"; label1.font = [UIFont systemFontOfSize:23]; label1.textColor = [UIColor whiteColor]; [self.view addSubview:label1]; [label1 release]; } }- (void)fadeScreen{ [UIView beginAnimations:nil context:nil]; // begins animation block [UIView setAnimationDuration:0.75]; // sets animation duration [UIView setAnimationDelegate:self]; // sets delegate for this block [UIView setAnimationDidStopSelector:@selector(finishedFading)]; // calls the finishedFading method when the animation is done (or done fading out) self.view.alpha = 0.0; // Fades the alpha channel of this view to "0.0" over the animationDuration of "0.75" seconds [UIView commitAnimations]; // commits the animation block. This Block is done.}- (void) finishedFading{ [UIView beginAnimations:nil context:nil]; // begins animation block [UIView setAnimationDuration:0.75]; // sets animation duration self.view.alpha = 1.0; // fades the view to 1.0 alpha over 0.75 seconds myviewcontroller.view.alpha = 1.0; [UIView commitAnimations]; // commits the animation block. This Block is done. for(UIView *mylabelview in [self.view subviews]) { if ([mylabelview isKindOfClass:[UILabel class]]) { [mylabelview removeFromSuperview]; } } [splashImageView removeFromSuperview];}
The above code implements a simple progress startup animation for your reference.