I have this particular code
let genderOptions = ["Male".localized, "Female".localized] .map { UIAction(title: $0, state: .off, handler: {_ in }) }genderButton.changesSelectionAsPrimaryAction = truegenderButton.menu = UIMenu(children: genderOptions)
Image may be NSFW.
Clik here to view.
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.
Image may be NSFW.
Clik here to view.
But when I print the selectedElements
, it prints the following:
print(genderButton.menu?.selectedElements)
Image may be NSFW.
Clik here to view.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.