I have this particular code
let genderOptions = ["Male".localized, "Female".localized]
.map { UIAction(title: $0, state: .off, handler: {_ in }) }
genderButton.changesSelectionAsPrimaryAction = true
genderButton.menu = UIMenu(children: genderOptions)
I have set all the UIAction
's state
to .off
, but still it is selecting the first item by default. Below is the Apple's documentation.
But when I print the selectedElements
, it prints the following:
print(genderButton.menu?.selectedElements)
even though all the
UIAction
items state = .off
, it prints an array with the first item as selected.
Q: How to have an initial state without any selection? Is popup button a good option to use here or should I use UITextField with UIPickerView? If anyone could give a complete solution, it would be great.