Show a view just once in whole life cycle of an App

后端 未结 1 1387
抹茶落季
抹茶落季 2021-01-16 04:11

I am working on a shopping app and on app launch, it shows signup view and once skip button is clicked it navigates to home view. I want to show signup view just once in who

相关标签:
1条回答
  • 2021-01-16 04:38

    Adding here the code I used to show walkthrough screen only once in the entire application lifecycle. This can be useful to you.

       // show walkthough for first time only (first time the app launches after download).
        bool shownFlag = [[NSUserDefaults standardUserDefaults] boolForKey:@"walkthroughShownOnce"];
        if(!shownFlag){
            [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:@"walkthroughShownOnce"];
            [[NSUserDefaults standardUserDefaults] synchronize];
            WalkThroughViewController *vc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"WalkThroughViewController"];
            [self.window makeKeyAndVisible];
            [self.window setRootViewController:vc];
        }else{
            //if not walkthough go and check other task
    
        }
    
    0 讨论(0)
提交回复
热议问题