objective c - iOS and xcode: how to create a modal segue to a special view only the first time the app is used

问题描述:

I want to make a "terms and conditions" screen that pops up the very first time that app is opened. On this view I would add a button that says "agree," and upon clicking it the code would execute:

[self dismissViewControllerAnimated:YES completion:nil];

...and would go to the first view of the app.

I am currently using a Tab Bar Controller that has 4 ViewControllers. So basically, I just need to have some method in viewWillAppear on my first ViewController that checks for an NSUserDefault key:value. The first time the app opens, it will be zero. After they click agree, I'll set it to 1 and the bit of code would never execute again.

Can you please offer some code to accomplish the task of routing the view from the firstViewController's view to this alternate view controller upon loading the app?

Thanks!

网友答案:

In the viewWillAppear method in your FirstViewController, check NSUserDefaults then present your TermsViewController. After user click agree in TermsViewController, set NSUserDefaults then call