RSS

How to SplashScreen Display in the iPhone

31 Aug

By:  Sushant

In this application we will se how to display SplashScreen. When user run the application, it will show the splashScreen after some time it will automatically remove from the Screen. Basically this is the very simple application. So just have a look, how it will be worked.

In this application we will se  how to display SplashScreen. When user run the application, it will show the splashScreen after some time it will automatically remove from the Screen. Basically this is the very simple application. So just have a look, how it will be worked.

Step 1: Create a View base application using template. Give the application name “DisplaySplashScreen”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the DisplaySplashScreenViewController class for you. Expand Resources and notice the template generated a separate nib, DisplaySplashScreenViewController.xib, for the “DisplaySplashScreen”.

Step 4: We need to add the resource file called as “themes.png” into the resource folder. Select resources and add files existing sources and select the themes.png.

Step 5: In the DisplaySplashScreen.h file, we have added UIView for display the screen and mention two methods. So make the following changes:

@interface DisplaySplashSceenViewController : UIViewController {
IBOutlet UIView *displaySplash;
}
-(void)displayScreen;
-(void)removeScreen;

Step 6: Double click your DisplaySplashScreen.xib file open it to the Interface Builder. Drag the view from the library and place it to the Main Window(See the figure1 below). Open the second view icon from the MainWindow,drag the image view from the library and place it to the view window,select the view and bring up Attribute Inspector select the image “themes.png”. Select the File’s Owner icon from the MainWindow and bring up Connection Inspector, drag from the displayScreen to the last view icon (See the figure2 below) and connect File’s Owner icon to the view (See the figure3 below). Now save it , close it and go back to the Xcode.

Figure1: MainWindow

Figure 2: Connection Between displayScreen and View icon.

Figure 3: Connection Between File’s Owner icon to the View icon.

Step 7: Open the DisplaySplashScreen.m file, you will see here splash will be displayed 4 to 5 sec in the main screen after that splash screen will be removed from the Main Screen. So make the following changes:

-(void)displayScreen
{
UIViewController *displayViewController=[[UIViewController alloc] init];
displayViewController.view = displaySplash;
[self presentModalViewController:displayViewController animated:NO];
[self performSelector:@selector(removeScreen) withObject:nil afterDelay:4.0];
}-(void)removeScreen
{
[[self modalViewController] dismissModalViewControllerAnimated:YES];
}

Step  8: In the DisplaySplashScreenAppDelegate.m file make the following changes in the file.

– (void)applicationDidFinishLaunching:(UIApplication *)application {[window addSubview:viewController.view];
[window makeKeyAndVisible];
[viewController displayScreen];
}

Step 9: Now compile and run the application in the Simulator.

You can downloaded SourceCode from here DisplaySplashSceen 2

Referenced by: http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-splashscreen-display-in-the-iphone/

Advertisements
 
Leave a comment

Posted by on August 31, 2012 in iOS

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: