Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you have an example code for the 'sort' drop down you show in the screen shot? #30

Open
netsmith opened this issue Feb 26, 2020 · 2 comments
Assignees

Comments

@netsmith
Copy link

the version where there is up and down arrows and also the segment where you select what you want to sort on? Its spot on what I'm looking for.

Thanks

@qmathe
Copy link
Owner

qmathe commented Mar 1, 2020

Hello,

Here is the code I was using for the menu visible in the screenshot you're referring to:

let sortCell = DropDownMenuCell()
let sortSwitcher = UISegmentedControl(items: localizedSortingChoices)
		
allowedSortingKeys = ["name", "rating", "distance", "creationDate"]

sortSwitcher.apportionsSegmentWidthsByContent = true
sortSwitcher.selectedSegmentIndex = allowedSortingKeys.index(of: sortingKey)!
sortSwitcher.addTarget(self, action: #selector(PlaceListController.sort(_:)), for: .valueChanged)

sortCell.customView = sortSwitcher
sortCell.textLabel!.text = "Sort"
sortCell.imageView!.image = UIImage(named: "SortingArrows")
sortCell.showsCheckmark = false
sortCell.layoutMargins = .zero
sortCell.preservesSuperviewLayoutMargins = false

dropDownMenu.menuCells = [selectCell, sortCell]

The code was written for iOS 8 to 11, I haven't tested it for more recent iOS versions, so you might need to adjust it.

@qmathe qmathe self-assigned this Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants