KarimEbrahemAbdelaziz / SwiftyMenu

Simple and Elegant Drop down menu for iOS 🔥💥
MIT License
573 stars 56 forks source link

Default Value #33

Closed idrenn closed 1 month ago

idrenn commented 2 years ago

Hi there, Thank you for your efforts!

How can we set Default Value?

We have an array ([Model(name:"CC"), Model(name:"FC"), Model(name:"FF")]) so we want to display "CC" on landing controller. We are able to set the index ("selectedIndex") but how can we set the text of that index?

Here is my code:

private func setupAssetOwnerDDMenu() {

    dropdown.delegate = self
    dropdown.configure(with: dropdownMenuAttributes)

    dropdown.items = dropdownOptionsDataSource

    dropdown.selectedIndex = 0
    **dropdown.selectButton  (select button is a private property so I can not set title)**
}
SamH2022 commented 2 years ago

@idrenn , DropdownMenu.selectedIndex = index would work and set your selected text too if you place it inside viewDidAppear , please refer to this question:

KarimEbrahemAbdelaziz commented 1 month ago

@idrenn just as @SamH2022 said. Thank you :)