views:

1682

answers:

4

Hi, In my TabBar based iPhone application, i would like to display a full screen welcome page (with some logs) before the actual application loads, How can i load a UIView from xib file as the welcome screen and then from there i can load my TabBar based application.

Thanks in advance,

+1  A: 

I add a subView to the main window in the appDelegate:

LoginViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
                                                                             bundle: nil];
[window addSubview: [loginController view]];

Then in the LoginViewController, when I'm ready to dismiss the View (to show YOUR tabController say) I do:

UIView *currentView = self.view;
UIView *theWindow = [currentView superview];

[currentView removeFromSuperview];

CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
Mr-sk
hai,Thanks for the quick response, i tried the code, its working, but there is a small gap in the bottom (i can see the tab bar in the background), its almost in the size of a status bar on the top. i think the view is not loading the correct origin. do you have any idea why its so ?
shinto Joseph
Hmm..I don't know - do you have something on your spring/struts set that could be making the view load off a little?
Mr-sk
A: 

In one of my tab-bar apps, I display a splash screen like so:

In my app delegate object, I start displaying it in didFinishLaunchingWithOptions

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    splashScreenVC = [[SplashScreenViewController alloc] initWithNibName:@"SplashScreenView" bundle:nil];

    [window addSubview:splashScreenVC.view];
    [window makeKeyAndVisible];

    //set delay before showing new screen
    [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(onSlashScreenExpired:) userInfo:nil repeats:NO];

    return YES;
}

The onSlashScreenExpired method looks like:

- (void)onSlashScreenExpired:(id)userInfo{
    [splashScreenVC.view removeFromSuperview];
    [splashScreenVC release];

    // At this point, create the tab bar controller and display it
}

I'm fairly certain I cobbled this together from another question on SO, but I can't find it.

Dana
hai,Thanks for the quick response, i tried the code, its working, but there is a small gap in the bottom (i can see the tab bar in the background), its almost in the size of a status bar on the top. i think the view is not loading the correct origin. do you have any idea why its so ?
shinto Joseph
Oh yeah, I think that happened to me too. I'm trying to remember what I did...in your controller in the nib, have you set it to be 320x480 in seize and set Status Bar, Top Bar and Bottom Bar all to None?
Dana
size of the view is 320x460 and status bar is on
shinto Joseph
+1  A: 

The right way to do this would be to load your tab bar application normally, but use the presentModalViewController:animated: method of the tab bar controller to display a view controller over it (in application:didFinishLaunching:):

SplashScreenController *controller = [[SplashScreenController alloc] initWithNibNamed:nil bundle:nil];
[self.tabBarController presentModalViewController:controller animated:YES];
[controller release];

I'll usually put a "dismiss" button on the splash screen, but you could also do something like this:

[self.tabBarController performSelector:@selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:2.0];

which will present the view controller at launch and dismiss it after two seconds. Change the YESes to NOs to avoid the slide-up-from-the-bottom animation.

Frank Schmitt
Hi, I tried and its loading the view[window addSubview:tabBar.view];[window makeKeyAndVisible];[self.tabBar presentModalViewController:controller animated:NO];I put a button in the SplashScreen to dismiss and the code i used to dismiss the view is UIView *currentView = self.view;[currentView removeFromSuperview];it will dismiss the splash screen, but not showing the TabBar. could you please help me to solve this ?
shinto Joseph
What you want to do is call `[self.parentViewController dismissModalViewControllerAnimated:YES]` (or `NO`).
Frank Schmitt
Thank you so much......
shinto Joseph
+3  A: 

The UI guidelines say you shouldn't have a splash screen - you should present a dummy version of the view the user will see when the application loads, without any data in it:

see Apple iPhone UI Guidelines on Launch Images for details - here's an excerpt:

To enhance the user’s experience at application launch, you should provide a launch image. A launch image looks very similar to the first screen your application displays. iPhone OS displays this image instantly when the user taps your application icon on the Home screen. As soon as it’s ready for use, your application displays its first screen, replacing the launch placeholder image.

It’s important to emphasize that the reason to supply a launch image is to improve user experience; it is not an opportunity to provide:

  • An “application entry experience,” such as a splash screen
  • An About window
  • Branding elements, unless they are a static part of your application’s first screen
Alex Brown
Second that! Do not use splash screens, they're frowned upon by the iPhone reviewers.
Adam Woś
This is hogwash, IMO (Apple's reasoning, that is). They say "...a launch image is to improve user experience..." What's a worse user experience than staring at an empty table waiting for your data to load? The old adage about "time on hold appears to last 3x longer than actual time spent on hold" applies here, too: I wouldn't notice the time spent waiting if it wasn't so blatantly obvious that I was waiting on that empty table to fill with my data. I'd much rather that happen in the background while the developer's logo fades in and out (or something). Give me something to look at.
Andy