簡體   English   中英

如何使WSCoachMarksView演練僅在用戶首次打開應用程序時運行?

[英]How to make WSCoachMarksView walkthrough only run the first time user opens app?

我正在使用WSCoachMarksView來給我的用戶第一次打開應用程序的過程,我顯然只希望它在第一次運行,此后不再運行。 我按照文檔中的說明進行操作,該文檔告訴您將我擁有的相應代碼放入viewDidAppear ,以使其僅運行一次,但似乎不起作用。

每次打開應用程序時,它仍將通過演練運行。 我有什么做的不好,無法檢測到先前運行的應用程序並設置了BOOL使其不再運行?

SearchViewController.m:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Setup coach marks
    NSArray *coachMarks = @[
                            @{
                                @"rect": [NSValue valueWithCGRect:(CGRect){{50,168},{220,45}}],
                                @"caption": @"Just browsing? We'll only notify you periodically of new matches. Need it soon? We'll notify you more frequently, and match you with items that are closer to you."
                                },
                            ];

    self.coachMarksView = [[WSCoachMarksView alloc] initWithFrame:self.tabBarController.view.bounds coachMarks:coachMarks];
    [self.tabBarController.view addSubview:self.coachMarksView];
    self.coachMarksView.animationDuration = 0.5f;
    self.coachMarksView.enableContinueLabel = YES;

    [self.coachMarksView start];
}


- (void)viewDidAppear:(BOOL)animated {
    // Show coach marks
    BOOL coachMarksShown = [[NSUserDefaults standardUserDefaults] boolForKey:@"WSCoachMarksShown"];
    if (coachMarksShown == NO) {
        // Don't show again
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WSCoachMarksShown"];
        [[NSUserDefaults standardUserDefaults] synchronize];

        // Show coach marks
        [self.coachMarksView start];
    }
}

在viewDidLoad中,無論您在NSUserDefaults中進行了什么設置,您始終都會啟動介紹。 viewDidAppear中的檢查是正確的,但當時已經在播放

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM