How to make scollView (for T&C) only show up once at begin of app, then never show up again?

て烟熏妆下的殇ゞ 提交于 2019-12-12 01:48:13

问题


My questions is...how to make....this... I am trying to make a scollview to show the term&condition at beginning of my app when the user is 1st time using the app. if the user accepted the T&C (by clicking accept button), this T&C scollview will never show up again at beginning of the app, as he already accepted. So he will be free to use the app in future. How do I implement this? any suggestions?


回答1:


Use NSUserDefaults with a key like "TCShown". If the key does not exist in the NSUserDefaults at the beginning of the launch, you show the T&C and create "TCShown" value, set it to YES ([NSNumber numberWithBool:YES];) and store it to the NSUserDefaults.

Edit:

Assuming that you want to present the T&C in your first viewController,

#define kTCViewedFlag = @"tcViewed" 

-(void) viewDidAppear {

NSUserDefaults *myDefaults = [NSUserDefaults standardUserDefaults];

if(![myDefaults objectForKey:kTCViewedFlag]) {

//show the TC
    }

}


-(IBAction) userAcceptedTC {

[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kTCViewedFlag];

[[NSUserDefaults standardUserDefaults] synchronize];
//dismiss the scrollView
}

-(IBAction) userDidDeclineTC {

//handle refusal of TC

}



回答2:


In addition to Kaan's answer, you can add the TCShown field to the server and update the values accordingly. This will take care of the case when the user who has already accepted the T&C's logs in from a different device.




回答3:


Maybe you'll find this useful: RLAgreement View Controller

This project allows developers to include and Agreement, Terms of Service, Non Disclosure Agreement, etc. to an iPhone App. The controller stores a variable in the user's settings when the user has a valid agreement and it checks every time the user opens the App.



来源:https://stackoverflow.com/questions/11949762/how-to-make-scollview-for-tc-only-show-up-once-at-begin-of-app-then-never-sh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!