私は、アプリを起動したときに一度しか表示されないポップアップウィンドウを作成する方法を理解しようとしています。 。ただし、以下のコードを表示すると、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