未分類

アラートを表示する

投稿日:

アラートを表示するメソッド

//アラート
    func displayAleart() {
        let alert: UIAlertController = UIAlertController(title: "アラート表示", message: "保存してもいいですか?", preferredStyle:  UIAlertController.Style.alert)

        let defaultAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:{
            (action: UIAlertAction!) -> Void in
            print("OK")
        })
        let cancelAction: UIAlertAction = UIAlertAction(title: "キャンセル", style: UIAlertAction.Style.cancel, handler:{
            (action: UIAlertAction!) -> Void in
            print("Cancel")
        })

        alert.addAction(cancelAction)
        alert.addAction(defaultAction)

        present(alert, animated: true, completion: nil)
    }

参考:【Swift】アラートを表示する(Alert/ActionSheet)

-未分類

執筆者:

関連記事

no image

TextFieldがキーボードで隠れるのを防ぐ(ライブラリ使用)

TextFieldがキーボードで隠れるのを防ぐのに、以前の記事ではNotificationCenterを使う方法を書いた。 キーボードでtextFieldが隠れないようにする しかし、このやり方では、 …

no image

StaticCellでコードから特定のセルを選択状態にしたい時

セルを選択したいタイミングに以下のコードを書く。 sectionとrowでセルを指定する。 tableView.selectRow(at: IndexPath(row: 0, section: 1), …

no image

テキストアニメ、モーションのフリーテンプレート使い方

【商用利用OK】Premiere Proのテキストアニメーション・テンプレート100種類 .mogrtのフォントがpremiere proで変更できない時の対処法

no image

GoogleService-Info.plistでエラーが出た時の対処法

エラ〜:reason: ‘[FIRApp configure]; (FirebaseApp.configure() in Swift) could not find a valid Goo …

簡単なイーズの付け方

アニメーションの最初のキーフレームに「イーズアウト」、最後のキーフレームに「イーズイン」を入れる。右クリックでメニュー出てくる。 こうすることで、最初ゆっくり入ってきて、中間でピークをむかえ、最後にゆ …