loading an inital view then suspending after delay

Discussion in 'iOS Programming' started by bobbypotluck, Jun 18, 2010.

  1. bobbypotluck macrumors member

    Joined:
    Feb 18, 2009
    #1
    i'm trying to load an initial view with an image for 5 seconds and then suspend and load a tabBarController in my AppDelegate file. At the moment i can only load one or the other.

    I tried creating a method inside the initalviewcontroller to suspend the view after delay but Xcode gives me a warning that my ViewController may not respond to the method in the appDelegate file. Here's my code at the moment

    App Delegate File Code

    Code:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    	
    	SplashViewController *theSplashViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];	
    	// Override point for customization after application launch
    	[window addSubview:[theSplashViewController view]];
            [window makeKeyAndVisible];
    	[splashController showSplash];
    	[window addSubview:[rootTabBarController view]];
    	
    	return YES;
    }
    And the code for the method in the viewController file

    Code:
    -(void)showSplash
    {
        UIViewController *modalViewController = [[UIViewController alloc] init];
        modalViewController.view = splash;
        [self presentModalViewController:modalViewController animated:NO];
        [self performSelector:@selector(hideSplash) withObject:nil afterDelay:5.0];
    }
    
    //hide splash screen
    - (void)hideSplash
    {
        [[self modalViewController] dismissModalViewControllerAnimated:YES];
    }
    Is there a better or easier way to do this?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    There is, but I'm just gonna suggest you avoid the splash screen altogether. Many users find them annoying. If you have an image to display at startup, make that your Default.png and then get on with things.
     
  3. bobbypotluck thread starter macrumors member

    Joined:
    Feb 18, 2009
    #3
    i would agree, but i want a random image loaded every time from a group of images. I tried the default.png but did not like it. it loaded too fast and i want more than just that image loaded.
     

Share This Page