I want to make a guided tour of my app on the first launch, but not a separated guided tour where I show images of the app. I'd like to have multiple chat-bubbles just like this one:
And when I click somewhere on the screen, the next one pops up. I haven't found a single tutorial for this on the web, so maybe I'm just not using the right keywords...
Anyways, thanks a lot !
You can use an Int e.g. int firstLaunch and save it with NSUserDefaults to detect first launch. Then add a view to the UIView in the story board and make it fill the Application screen and give it a grey color and and transparency.
Then add the images of the bubble in the position you want them in the view.
Below would go in the ViewDidLoad:
firstLaunch = [[NSUserDefaults standardUserDefaults] integerForKey:#"FirstLaunch"];
if (firstLaunch == 0) {
firstLaunch = 1;
[[NSUserDefaults standardUserDefaults] setInteger:firstLaunch forKey:#"FirstLaunch"];
ViewName.hidden = NO;
bubble1Image.hidden = NO;
}
Related
This question already has answers here:
Show screen on first launch only in iOS
(8 answers)
Closed 5 years ago.
I'm trying to create an tutorial screen that displays only during the first opening of an app. i know i should use user defaults but how and where ? in method viewDidLoad or on app delegate class ?
Try this one
- (BOOL)isAppAlreadyLaunchedOnce {
BOOL isRememberMe = [[NSUserDefaults standardUserDefaults]boolForKey:#"isAppAlreadyLaunchedOnce"];
if (isRememberMe) {
return YES;
}
else{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"isAppAlreadyLaunchedOnce"];
return NO;
}
}
Store the status whether the Tutorial View is displayed or not in NSUserDefaults.
If you want to decide at startup to show or not show the Tutorial View you should do it in App Delegate didFinishLaunchingWithOptions
if(![[NSUserDefaults standardUserDefaults] boolForKey:#"shouldShowTutorial"])
//show tutorial
}
else{
//don't show tutorial
}
On the first time when the Tutorial View has been displayed set a flag in NSUserDefaults.
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"shouldShowTutorial"];
#Maddy has given correct answer but let me just clarify one thing why we will not use viewDidLoad?
Why we are using didFinishLaunch
in short:
viewDidLoad
System has already decided which View to load when application launches .By default it's the "Main" storyboard's initial view controller
didFinishLaunch
System has done all tasks to show your app but has not decided which view to load. Thats why you can control here to show your tutorial screen first. :)
How do I know, how much keyboards enabled into my iPhone keyboard settings.
Even if user downloaded other custom keyboard from app store, still I want in list programmatically.
NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:#"AppleKeyboards"]; // Array of all active keyboards
NSLog(#"List of all keyboards : %#",keyboards);
You can ask current first responder (UITextField, UISearchBar, etc.).
// assume you have instance variable pointing to search bar currently entering
UITextInputMode *inputMode = [self.searchBar textInputMode];
NSString *lang = inputMode.primaryLanguage;
The first time you access a mobile app or when there's an update, there will be a few screens that highlight features in the app (a what's new/tutorial modal). I've seen some of these images animate within the screen. A recent good example I've seen was the MS Office's suite of iPad apps. The images they use look like they are being drawn. To be clear, I am not referring to an animated loading screen when first launching the app. This is usually a modal that shows up when you select a "get started" or "learn more" type of button.
I've tried looking through a couple forums and general searching but I haven't found any best practices (or even info on how). Are these animations a video, an animated image (gif?), a series of moving panes that are uncovering the image in a certain way? I would think the best method for doing this is also cognizant of the file size so as not to bulk up the app size significantly.
Also, is there a common term/name for these intro screens? I've seen some sites use "walkthroughs" but that also refers to product video tutorials occasionally.
Any advice or information is appreciated! Thanks!
you could do a video, or a fullscreen image. You could also do something like create a UIView for each step of your walkthrough and then put the inside of a scrollview and let the user flip through them like in a photo app. You could do something like a PageViewController as well. Or you could get really fancy and have view controllers with animation code and all the like.
As for how to decide when to show the walkthrough NSUserdefaults is a great tool.
if (![[NSUserDefaults standardUserDefaults] boolForKey:#"HasShowWalkthroughForVersion1"]) {
//save that we've show the walkthrough in user defaults
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"HasShownWalkthroughForVersion1"];
[[NSUserDefaults standardUserDefaults] synchronize];
//show walkthrough
....
}
For iOS you can use local storage to detect if the user is running the app for the first time for example this piece of code plays a movie the first time the user runs the app
NSString *bundleVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
NSString *appFirstStartOfVersionKey = [NSString stringWithFormat:#"first_start_%#", bundleVersion];
NSNumber *alreadyStartedOnVersion = [[NSUserDefaults standardUserDefaults] objectForKey:appFirstStartOfVersionKey];
if(!alreadyStartedOnVersion || [alreadyStartedOnVersion boolValue] == NO) {
// first start of the current version
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"playMovie"];
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:appFirstStartOfVersionKey];
[[NSUserDefaults standardUserDefaults] synchronize];
[self performSelector:#selector(showVideoThenLaunch) withObject:nil afterDelay:0.0];
}else{
UIView *statusBg = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,20.0)];
statusBg.backgroundColor = [UIColor whiteColor];
[self.window addSubview:statusBg];
}
Animating a series of images - you can set a series of Images for a UIImageView, in this example a series of images are repeated
// animation on home screen
bearPaw = [[UIImageView alloc] initWithFrame:CGRectMake(40, 270, 254, 141.5)];
// load all the frames of our animation
bearPaw.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"swipe1"],
[UIImage imageNamed:#"swipe2"],
[UIImage imageNamed:#"swipe12"],
[UIImage imageNamed:#"swipe13"],
[UIImage imageNamed:#"swipe14"], nil];
// all frames will execute in 1.75 seconds
bearPaw.animationDuration = 1.0;
// repeat the annimation forever
bearPaw.animationRepeatCount = 3;
// start animating
[bearPaw startAnimating];
// add the animation view to the main window
[self.view addSubview:bearPaw];
My UISegmentedControl will not stay selected. I have made sure that momentary is NO. So the solutions I have come across on here have not helped.
Would someone please be able to point me in the right direction?
EDIT
Thought I might make this question a bit clearer.
I have a UISegmentedControl and it has four selections (10,20,30,40) which changes the amount of questions asked on my quiz page. Making a selection works fine and changes the amount of questions.
But when I leave that view and go back later on to change the amount of questions again, it shows the selected as 10 even if I have selected something else.
How can I keep it showing the actual selected value?
EDIT
The number of questions is saved in NSUserDefaults.
[[NSUserDefaults standardUserDefaults] setInteger:amountOfQuestions forKey:#"Amount"]
How do I initialize a segmented control with a value from NSUserDefaults?
EDIT - Solved
#SettingsViewController .m file.
- (void)viewDidLoad
{
amountOfQuestions = [[NSUserDefaults standardUserDefaults] integerForKey:#"Amount"];
if (amountOfQuestions == 10) {
mySegment.selectedSegmentIndex = 0;
}
I did not have the below code in my IBAction for my segmented control. So when i tried the above code it did not work. Now it works a treat.
[[NSUserDefaults standardUserDefaults]synchronize];
#SettingsViewController .m file.
- (void)viewDidLoad
{
amountOfQuestions = [[NSUserDefaults standardUserDefaults] integerForKey:#"Amount"];
if (amountOfQuestions == 10) {
mySegment.selectedSegmentIndex = 0;
}
I did not have the below code in my IBAction for my segmented control. So when i tried the above code it did not work. Now it works a treat.
[[NSUserDefaults standardUserDefaults]synchronize];
This question already exists:
Load up different view on first run
Closed 9 years ago.
I'm programming an app at the moment which requires on the first run for the app toload a different view in which the user can select its prefered settings.Here's the code
implementation AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// Determining Storyboard identifier for first view
// Determining Storyboard identifier for first view
NSString *storyboardID = [self hasEverBeenLaunched]? #"MainView" : #"LoginView";
// Setting proper view as a rootViewController
self.window.rootViewController = [self.window.rootViewController.storyboardinstantiateViewControllerWithIdentifier: #"view45"] ;
It then goes on with the following code:
- (BOOL)hasEverBeenLaunched
{
// A boolean which determines if app has eer been launched
BOOL hasBeenLaunched;
// Testig if application has launched before and if it has to show the home-login screen to login
// to social networks (facebook, Twitter)
if ([[NSUserDefaults standardUserDefaults] boolForKey:#"HasAlreadyLaunched"]) {
// Setting variable to YES because app has been launched before
hasBeenLaunched = YES;
NSLog(#"App has been already launched");
} else {
// Setting variable to NO because app hasn't been launched before
hasBeenLaunched = NO;
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"HasAlreadyLaunched"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(#"This is the first run ever...");
}
return hasBeenLaunched;
}
Just a few quick notes: View 45 is the initial starting up view which should only show once, Otherwise the main view controller is ticked under atrributes to be the initial view controller(The one that always loads up at the start, after the first run)
So the problem is that it only ever loads view 45 ,the first run view, but whats causing that exactly ?
The problem is in the following line:
self.window.rootViewController = [self.window.rootViewController.storyboardinstantiateViewControllerWithIdentifier: #"view45"] ;
It is ignoring the value of storyboardID and just using the string #"view45", so that's why you'll always get the same one every single time.
If you want to fix it, change it to the following line:
self.window.rootViewController = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:storyboardID];
You can see that now it is making use of the value in storyboardID.