KarimEbrahemAbdelaziz/SwiftyMenu

Default Value

idrenn opened this issue · 2 comments

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)**
}

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

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