Narendra Pandey Narendra Pandey - 29 days ago 14
Objective-C Question

Splash screen in ios

Please suggest me that how to create splash screen in iphone for some interval. i have tried to update in info.plist by creating a new resources Launch image But not working.
I have tried this

#import "AppDelegate.h"
#import "SignIn.h"
#import "Splash.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
Splash *splash=[[Splash alloc]initWithNibName:@"Splash" bundle:nil];
self.window.rootViewController=splash;
[self.window makeKeyAndVisible];
sleep(3);
SignIn *signIn=[[SignIn alloc]initWithNibName:@"SignIn" bundle:nil];
self.window.rootViewController=signIn;
return YES;
}

Answer

To present a view controller automatically after sometime add NSTimer in viewDidLoad of the splash screen controller which you are presenting.

- (void)viewDidLoad
{

//NSTimer calling Method B
[NSTimer scheduledTimerWithTimeInterval:5.0f 
target:self selector:@selector(methodB:) userInfo:nil repeats:NO];
}

- (void) methodB:(NSTimer *)timer
{
//Present next view controller.
}