[Swift] How to use one option alert

What is an alert?

It is the one that displays like an image. It comes out often, so I will summarize it this time. スクリーンショット 2020-12-10 21.45.42.png

How to write

How to write an alert consisting of title, message, and button like an image

スクリーンショット 2020-12-13 12.15.59.png The title of the alert and its contents are assigned to the constant dialog. Then add the action with addAction in the dialog. The additional content is the OK part of the image. Finally, self.present will display the alert you just created.

   let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
        self.present(alert, animated: true, completion: nil)

Finally

This time I wrote about an alert with one option. I will also write about other types.

Recommended Posts

[Swift] How to use one option alert
[Swift] How to use UserDefaults
How to use Swift UIScrollView
[Swift] How to use SwiftLint (cocoapods)
[Swift] How to use Unwind segue
[Swift] How to use Tab Bar Controller
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use java.util.logging
How to use map
How to use Twitter4J
How to use active_hash! !!
How to use hidden_field_tag
[How to use label]
How to use identity
How to use hashes
How to use JUnit 5
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to use Map
[Java] How to use Map
How to use Chain API
[Java] How to use Map
How to use Priority Queuing
[Rails] How to use enum
How to use java Optional
How to use JUnit (beginner)
How to use Ruby return
[Rails] How to use enum
How to use @Builder (Lombok)
How to use java class
How to use Big Decimal
[Java] How to use Optional ②
[Java] How to use removeAll ()
How to use String [] args
[Java] How to use string.format
How to use rails join
How to use Java Map
Ruby: How to use cookies
How to use dependent :: destroy
How to use Eclipse Debug_Shell
How to use Apache POI
[Rails] How to use validation
How to use Java variables
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
How to use GC Viewer
[Java] How to use Optional ①
How to use Lombok now
[Creating] How to use JUnit
[Rails] How to use Scope
[Swift] How to install Firebase ~ How to use Realtime Database & Cloud Firestore
How to use the link_to method
[Rails] How to use gem "devise"
How to use Lombok in Spring
How to use StringBurrer and Arrays.toString.
How to use arrays (personal memorandum)