Hello reader's !
If you want to setup first time launch of an iOS app.
Using this code the terms and conditions will appears or shown only the first time of app launch.
here is the code below.
I have two UIViewControllers (FirstViewController and AlreadyRunViewController). FirstViewController is for "Terms and Condition" page and if app is not running for first time then AlreadyRunViewController will appear .
So I have these files in my XCode :
Now, Go to to storyboard and give StoryBoard Id to "terms and condition" view controller.
Then go to your AppDelegate.m and paste below code :-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if ([[self alreadyRunOrNot] isEqualToString:@"runalready"]) {
NSLog(@"alreadyrun");
}
else
{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving user details to NSUserDefaults
[prefs setObject:@"runalready" forKey:@"alreadyRunOrNot"];
NSLog(@"run first time");
UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
FirstViewController *firstVC = [story instantiateViewControllerWithIdentifier:@"firstViewController"];
self.window.rootViewController =firstVC;
}
return YES;
}
Now storyboard will look like :-
0 Comment(s)