简体   繁体   English

如何只显示一次IOS7的视图控制器

[英]how to display view controller only once IOS7

Hi in my application i have small registration from in view controller now i want this registration form to display before the launch image display and it has to open only once when user open first after that it should not display that view controller it has to open the second view directly.Please tell me is this possible or not. 嗨,在我的应用程序中,我从视图控制器中进行了少量注册,现在我希望此注册表单在启动图像显示之前显示,并且在用户首次打开后它仅必须打开一次,因此它不应该显示该视图控制器而必须打开该视图控制器请直接告诉我第二种观点是否可行。

Possible means please tell what is right way to achieve this task i have searched everywhere but I'm not able to find the proper solution for this. 可能的方法是,请告诉我在各处搜索过的完成此任务的正确方法,但是我无法找到合适的解决方案。

In the register form after clicking the register button it has to go to the second view controller. 在注册表单中,单击注册按钮后,它必须转到第二个视图控制器。

It is possible to do this, 可以这样做

to check if the application is loaded for the first time, I recommend you use NSUserDefaults to store a value for that. 要检查是否是第一次加载该应用程序,建议您使用NSUserDefaults为其存储一个值。

    if (![[NSUserDefaults standardUserDefaults] valueForKey:@"firstRunCompleted"])
    {
         //Your code here which you want to run only for the first time.

    }

    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstRunCompleted"];
    [[NSUserDefaults standardUserDefaults] synchronize];

Since First time when the if is called there will not be any value for the key "firstRun". 自从第一次调用if以来,键“ firstRun”将没有任何值。 It will execute and once execution is complete, the value will be set to YES and hence the if will not be executed thereafter. 它将会执行,一旦执行完成,该值将被设置为YES,因此if将不会在之后执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM