Ios 是否使用UISwitch隐藏UIViewController?

Ios 是否使用UISwitch隐藏UIViewController?,ios,ios7,uiswitch,Ios,Ios7,Uiswitch,嗨,我正在开发一个应用程序,当你打开这个应用程序时,作为一个简短的教程,你可以看到一个带有PageViewController的UIViewController。我想知道你是否可以使用UISWitch来“隐藏”UIViewController,以便下次启动应用程序时它直接进入“主视图” 谢谢 英语是我的第二语言。首先,您需要为交换机设置一个操作: - (IBAction)valueChanged:(UISwitch *)theSwitch { [[NSUserDefaults stand

嗨,我正在开发一个应用程序,当你打开这个应用程序时,作为一个简短的教程,你可以看到一个带有PageViewController的UIViewController。我想知道你是否可以使用UISWitch来“隐藏”UIViewController,以便下次启动应用程序时它直接进入“主视图”

谢谢
英语是我的第二语言。

首先,您需要为交换机设置一个操作:

- (IBAction)valueChanged:(UISwitch *)theSwitch
{
    [[NSUserDefaults standardUserDefaults] setBool:theSwitch.isOn
                                            forKey:@"DontShowViewContoller"];
}
然后,下次要显示视图控制器时,请选中:

if([[NSUserDefaults standardUserDefaults] boolForKey:@"DontShowViewContoller"] == NO)
{
    [self showYourViewController]
}

如果你只是想第一次展示它,你不需要一个开关。只需使用
NSUserDefaults
来记住您以前是否运行过

应用程序中:使用选项完成启动:
方法:

if (![[NSUserDefaults standardUserDefaults] boolForKey:@"RunBefore"]) {
    //show pagecontroller here
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RunBefore"]

}