And as I mentioned in the previous part, I was not able to make the OK button take on the default styling. I was not able to get the focus into the TextField automatically when the sheet opened and I was not able to assign keyboard shortcuts to the Cancel and OK buttons so that they could be operated without a mouse. It was not obvious that these would also dismiss the alert dialog, but I tried anyway. This version showed a single dismissButton but I saw that there was a variation of Alert with primary and secondary buttons. Cancel actually has two variants and will use a label appropriate to the user’s locale if no label is supplied.Īgain, these buttons need a Text view as the label (if supplied) and can take an action closure, which I used to update my dialogResult string. I couldn’t find any documentation for this, but delving into the definition for Alert, I see that there are three pre-defined button types: default, cancel or destructive. Then there is the button which auto-suggest tells me is of type Alert.Button. If you get an error message that says “Cannot convert value of type ‘String’ to expected argument type ‘Text’”, then you have forgotten to use a Text view. Firstly, both title and message must be Text views, not strings. There were a few things that tripped me up in this relatively short chunk of code. Self.dialogResult = "OK clicked in Alert" })
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |