简体   繁体   English

iOS首次发布秀的条款和条件

[英]iOS First Launch show Terms and Conditions

i need help with the following code. 我需要以下代码的帮助。 My aim is to show the UIViewController "Terms" (already exists in my Storyboard and I have asigned the name Terms in the Storyboard ID). 我的目的是显示UIViewController“条款”(已经存在于我的情节提要中,并且我已在情节提要ID中分配了名称“条款”)。 If the app as already been opened and the user accepted the T&C then show the normal UIViewController. 如果该应用程序已经打开并且用户接受了条款和条件,则显示正常的UIViewController。

FIRSTVIEWCONTROLLER.H FIRSTVIEWCONTROLLER.H

#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController

@end

@interface First : UIViewController

@end

@interface Terms: UIViewController

@end

FIRSTVIEWCONTROLLER.M FIRSTVIEWCONTROLLER.M

#import "FirstViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad: (BOOL)animated
{
    [super viewDidLoad];



    NSUserDefaults * standardUserDefaults = [NSUserDefaults standardUserDefaults];

    BOOL isAccepted = [standardUserDefaults boolForKey:@"iHaveAcceptedTheTerms"];

    if (!isAccepted) {
        [self presentViewController:Terms animated:YES completion:nil];
    } else {
        [self.navigationController pushViewController:First animated:YES];
    }

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

As it is, I am receiving 2 errors: "Unexpected interface name 'Terms'/'First': expected expression". 就这样,我收到2个错误:“意外的接口名称'Terms'/'First':预期的表达式”。

Please take a look at the storyboard: http://i.stack.imgur.com/bi6aT.png 请看看情节提要: http : //i.stack.imgur.com/bi6aT.png

Help me please. 请帮帮我。 xcode beginner. xcode初学者。

First off, remove these lines from your .h since they're unnecessary: 首先,请从您的.h中删除这些行,因为它们是不必要的:

@interface First : UIViewController

@end

@interface Terms: UIViewController

@end

Secondly, your Storyboard doesn't look quite right... From the FirstViewController , you need to create segues between the view and both potential subsequent view controllers, ie "First" and "Terms", using the method I've specified here: https://stackoverflow.com/a/20690072/2274694 ; 其次,您的Storyboard看起来不太正确...在FirstViewController ,您需要使用我在此处指定的方法在视图与两个潜在的后续视图控制器(即“ First”和“ Terms”)之间创建序号: https://stackoverflow.com/a/20690072/2274694 ; then label those segues with identifiers. 然后用标识符标记这些标记。

That way, if you want to segue to the pertinent view controller depending on whether or not the terms have already been accepted, you could perform the segue using the relevant identifier, ex: 这样,如果您想根据是否已接受这些条款来选择相关的视图控制器,则可以使用相关的标识符执行选择,例如:

if (!isAccepted) {
    [self performSegueWithIdentifier:@"firstSegue" sender:self];
} else {
    [self performSegueWithIdentifier:@"termsSegue" sender:self];
}

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

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