gpt4 book ai didi

ios - 我想在第一次打开应用程序时创建提醒

转载 作者:行者123 更新时间:2023-11-30 12:24:00 25 4
gpt4 key购买 nike

我想在设备上第一次打开应用程序时创建警报,但我在代码方面遇到了一些问题。这就是我到目前为止所拥有的,任何帮助将不胜感激

    // alert first time app is opened
// making of alert

let alert = UIAlertController(title: "Navigation", message: "Tap Right Hand Side of Screen For Next Quote, Left Hand Side To Go Back", preferredStyle: UIAlertControllerStyle.alert)

//add ok button
alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.default, handler: nil))

// detect if first launch
let launchedBefore = UserDefaults.standard.bool(forKey: "launcedBefore")
if launchedBefore {
}
else {
self.present(alert, animated: true, completion: nil)
UserDefaults.standard.set(true, forKey: "launchedBefore")
}

这是我试图放置代码的地方

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

最佳答案

launchedBefore 键中有拼写错误将其更改为:

let launchedBefore = UserDefaults.standard.bool(forKey: "launchedBefore")

关于ios - 我想在第一次打开应用程序时创建提醒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44437306/

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