未分類

アラートを表示する

投稿日:

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

//アラート
    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

動画の速度を遅くしてクリップを引き伸ばす方法

commnd + R スロー・早送りで速度を変更できる。 参考: Premiere Pro 再生速度を変更(早回し・スローモーション動画)する手っ取り早い方法

no image

UserDefaultsとは

UserDefaultsとは UserDefaultsを使えばアプリ内にデータを保存することができる。 アプリを端末から消去しない限りずっと残り続ける。 入力途中のものやメモの保存に役立つ。 保存した …

no image

AutoLayoutでサイズを比率で指定する

control押しながら、基準にしたいもの(Viewとか)にドラッグ。 Equal HeightまたはEqual Widthsを選択。 Multiplierを50パーセントにしたいなら、0.5に設定。 …

no image

collectionViewCellにラベルを設置する2つの方法

collectionViewCellの中にLabelを配置したい。 1. StoryBoardで設置する方法 新たなファイルを作らず簡単に設置できる。 cell内にLabel配置→Tagを1にする→コ …

no image

xcodeでファイル名の変更をする

xcodeでファイル名の変更をする簡単な方法↓ 参考:Xcodeでファイルの名前を変更またはリファクタリングする