Showing onboarding Viewcontroller once

King

New Member
#1
I have an application where I am showing an onboarding screen. I now want the onboarding screen to show just once throughout the app life except the user delets and reinstall. That is the user can only see the onboarding once and when the user opens the app again, the user should be able to see the main page. I tried using Userdefaults in the AppDelegate didFinishLauchWithOptions but I could not get it to work well.
Mã:
if !UserDefaults.standard.bool(forKey: "didSee") {
    UserDefaults.standard.set(false, forKey: "didSee")
    let storyboard = UIStoryboard(name: "CategorySB", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier: Constants.CATEGORY_VC)
    self.window?.rootViewController = viewController
    self.window?.makeKeyAndVisible()
}
I have the onboarding in its own StoryBoard too OnBoardingSB and in the main app project, I made the Main Interface is the OnBoardingSB
any help would be appreciated
 

Admin

Administrator
Thành viên BQT
#2
You need to set it to true
Mã:
UserDefaults.standard.set(true, forKey: "didSee")
 
OP
OP
K

King

New Member
#3
Thanks. I would really want to meet the person behind this account. I am very grateful
 
Top