How to SplashScreen Display in the iPhone

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

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic, and free programming tips and tricks and source code            snippets.

2 Responses to “How to SplashScreen Display in the iPhone”

  1. Naseem says:

    Great!
    Thanks a bunch :)

  2. javi says:

    Thanks!

    Very helpfully code :)

Leave a Reply

Security Code:

learn iphone programming

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Our Mobile Training Courses

EDUmobile.ORG offers the following 4 Mobile Training Courses. Our iPhone Training Course is very popular, with over 200 developers in training.

learn iphone programming
© 2010 EDUmobile.ORG