2014-11-23 57 views
0

我使用WSCoachMarksView給我的用戶的演練他們第一次打開應用程序,而很明顯我只希望這運行的第一次,之後再也沒有。我跟着,告訴你把,我在viewDidAppear,使其只運行一次相應的代碼文檔中的說明,但它似乎並沒有工作。如何使WSCoachMarksView演練只運行一次用戶打開應用程序?

它仍然通過演練每一個應用程序是開放的時間運行。有沒有什麼我不能正確地檢測以前運行的應用程序,並設置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]; 
    } 
} 

回答

1

在viewDidLoad中始終啓動你的介紹,不管是什麼你在設定NSUserDefaults的。在viewDidAppear的檢查是正確的,但它在當時已經打

相關問題