gpt4 book ai didi

ios - 用户首次启动应用程序时显示教练标记 View Swift 3

转载 作者:搜寻专家 更新时间:2023-11-01 05:52:30 25 4
gpt4 key购买 nike

当用户首次启动应用程序时,我需要在 tableview 上启动教练标记/教程 View 。除非用户删除并重新安装应用程序,否则教练标记将永远不会再次显示。

我搜索了互联网,但无法找到简单的解决方案。哦,我是 Swift 的新手,所以请保持温和。 :)

编辑:这是我用过的。效果很好!

  override func viewDidAppear(_ animated: Bool) {
if !UserDefaults.standard.bool(forKey: "isSecondTime") {
let launchedBefore = UserDefaults.standard.bool(forKey: "isSecondTime")
if launchedBefore {
print("Not the first launch.")
} else {
let VC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CoachMarksViewController")
self.present(VC, animated: true, completion: nil)
print("This the first launch.")
UserDefaults.standard.set(true, forKey: "isSecondTime")
}

}
}

最佳答案

可能这就是您所需要的?

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated);
let kFirstLaunch = "First_launch"

if (UserDefaults.standard.object(forKey: kFirstLaunch) == nil) {
UserDefaults.standard.set(1, forKey: kFirstLaunch);
//Show your coach marks here

}
}

关于ios - 用户首次启动应用程序时显示教练标记 View Swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44396883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com