我想弄明白是如何創建一個彈出窗口,只有當您啓動應用程序時纔會出現一次,然後不會再次出現,除非您關閉應用程序並重新啓動它。但是,如果您查看下面的代碼,則會發現每次出現ViewController
時都會彈出警報。例如,如果您轉到「設置」選項卡,然後返回到主「ViewController
」,則會彈出警報。如何使警報只出現一次
override func viewDidAppear(animated: Bool) {
let alertController = UIAlertController(title: "Disclaimer", message: "WARNING: Please ride carefully!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Accept", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
}
的可能的複製[UIAlertView中或UiAlertController在夫特只有一次顯示](http://stackoverflow.com/questions/28285993/uialertview-or-uialertcontroller-to-display-only-once-in-swift ) – Caleb