Question

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

Was it helpful?

Solution

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

  • When the FirstPage loads, show the IntroPage view on top of it.
  • After a delay or when skip button is pressed, remove the IntroPage.

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.

OTHER TIPS

use nstimer to create some timer. The corresponding action will be executed after 10 sec or when skip button will be pressed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top