Reputation: 125
Hi im currently developing an app where when you open the app a UIViewController with a PageViewController as a short tutorial. Im wondering if you could use the UISWitch to "Hide" that UIViewController so that the next time you start the app it goes straight to the "Main View"?
Thanks PS. English is my second language.
Upvotes: 0
Views: 122
Reputation: 5953
If you just want to show it the first time, you don't need a UISwitch. Just use NSUserDefaults
to remember whether you've run before or not.
In your application:didFinishLaunchingWithOptions:
method:
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"RunBefore"]) {
//show pagecontroller here
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RunBefore"]
}
Upvotes: 2
Reputation: 40038
First you need to set an action for your switch:
- (IBAction)valueChanged:(UISwitch *)theSwitch
{
[[NSUserDefaults standardUserDefaults] setBool:theSwitch.isOn
forKey:@"DontShowViewContoller"];
}
Then, next time, when you want to show the view controller you check:
if([[NSUserDefaults standardUserDefaults] boolForKey:@"DontShowViewContoller"] == NO)
{
[self showYourViewController]
}
Upvotes: 0