I need to implement animated splash screen to the iPhone application. I have seen skype application where same thing is already implemented.
Can anyone has idea how can
We can show a .gif image in webView
and it looks perfect!
Take a new UIViewController
class named SplashView
with XIB
and then add an UIWebView
with (320.0, 480.0) frame, hidden statusbar
also.
In SplashView.h
#import
@interface SplashView : UIViewController
@property(nonatomic, retain)IBOutlet UIWebView *webView;
@end
In SplashView.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *imagePath = [[NSBundle mainBundle] pathForResource: @"animated" ofType: @"gif"];
NSData *data = [NSData dataWithContentsOfFile:imagePath];
[self.webView setUserInteractionEnabled:NO];
[self.webView loadData:data MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];
}
This is about SplashView
class. Now come to your appdelegate's class.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
splashView = [[SplashView alloc]initWithNibName:@"SplashView" bundle:nil];
[self.window addSubview:splashView.view];
[self performSelector:@selector(changeView) withObject:nil afterDelay:3.0];
[self.window makeKeyAndVisible];
return YES;
}
-(void)changeView
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[splashView.view removeFromSuperview];
[self.window setRootViewController:self.viewController];
}