iphoneiphone-sdk-3.0iphone-sdk-3.1

Intro Page for 5 Seconds after the default.png file and before the MainWindow.nib


I had created a project where the default.png sleeps for 3 seconds and then the MainWindow.xib is loaded I wanted to create a new IntroPageViewController.xib before the FirstPageViewController.xib loads . I wanted to put some text in the IntroPage which loads for 10 seconds and has a skip button . I already created the FirstPageViewController.xib , now I want to load IntroPageViewController.xib in applicationdidfinishlaunching .

I tried to make changes in the FirstPageAppDelegate.h and .m but still the FirstPageViewController.xib loads and if I make changes to info.plist to load IntroPageViewController.xib or IntroPageViewController the application crashes . Help needed please .

Thanks a ton in advance :)

Regards, Coder


Solution

  • Instead of loading the IntroPageViewController.xib ahead of the FirstPageViewController.xib manually, try this:

    Here's how:

    Make an IntroPageViewController with corresponding xib file.
    In Xcode, setup a button and an action method for that button.

    // in your .h file.   
    
    @interface IntroViewController : UIViewController {
        UIButton *skipButton;
    }  
    
    @property (nonatomic, retain) IBOutlet UIButton *skipButton;
    
    -(IBAction)skipPressed;
    
    @end  
    
    // in the .m file  
    
    -(IBAction)skipPressed {
        [self.view removeFromSuperview]; // this removes intro screen from the screen, leaving you FirstView
    }
    
    // put this in the viewDidLoad method
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        [self performSelector:@selector(skipPressed) withObject:nil afterDelay:5];
    }
    
    // add these in FirstViewController.m  
    
    #import "IntroViewController.h"  
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        IntroViewController *introViewController = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:[NSBundle mainBundle]];
        [self.view addSubview:introViewController.view];
        [introViewController release]; // this removes your IntroScreen from memory once it disappears offscreen
    }
    

    Now the next step is to open IntroViewController.xib in Interface Builder and drag a UIButton to the view, set its title to 'Skip'.

    Connect the button to the skipPressed action and connect File's Owner to the button.

    Go back to Xcode and Build and Run to test it. If all is well, your IntroView should be visible at launch time for 5 seconds or until you touch the Skip button.