开发者

How to add Terms and conditions view to my application so that it will be visible first time only

In my applications i hav a terms and conditions view describing terms to use when user selects agree he will go to sign in page otherwis开发者_运维技巧e not ,it must be visible to user at first time when application launched in his mobile after that it has to start up with sign in view

how can i do this ... any ideas appreciated....


You can use a flag on your NSUserDefaults. On your applicationDidFinishLaunch you would check for the flag, and if not present, show the disclaimer AND update the flag.

The code would be similar to this:

BOOL disclaimerAccepted = [[NSUserDefaults standardUserDefaults] boolForKey:@"disclaimerAccepted"];
if (!disclaimerAccepted) {
    [window addSubview:disclaimerView];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

When the user clicks the accept button, you can update the setting as follows:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"disclaimerAccepted"];

As @mvds suggests in the comments, it may be a good idea to store a number or string instead of a bool value, containing your app's version number. That way, you can force users to re-accept the terms and conditions when you update your app.


You can do this using NSUserDefaults.

In the applicationDidFinishLaunching method, look for the presence of a BOOL key that you place in NSUserDefaults. If it does not exist, run your code to show the terms and conditions, then set that variable to true in NSUserDefaults so it does exist next launch.


On your app startup use NSUserDefaults to check for the presence of a user setting with a name of your choosing (for example firstRunFinished or userAgrredToTerms). if that setting is present and has value of true (or YES), you proceed normally. if the setting is missing, or is present but has a value of false (or NO), push your terms and conditions view as a modal view at the top of your main controller view stack.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜