Reputation: 603
I want to show a drop-down menu on button click.I follow the below link for this.
https://richardallen.me/2014/11/28/popovers.html
But my button is in table view cell and I want to show the popup on below the button.I searched a lot and find the way by using popovers. But I don't know how to use and show it.If I follow the above link then below error is shown.And popup is shown on full screen.So please help me.
/Base.lproj/Main.storyboard:%20Couldn't%20compile%20connection:%20<IBCocoaTouchOutletConnection:%200x7fc9f5fa6330%20(KPd-LK-kJS)%20source=<IBProxyObject:%200x7fc9f5fa6020%20(mgH-pb-OhC)%20'Placeholder%20for%20UIStoryboardPopoverPresentationSegueTemplate%20with%20OID%20qoG-n8-Yu0'>%20property=anchorView%20destination=<IBUIButton:%200x7fc9f796dd40%20(xk1-Vu-vnj)%20'Anchor%20View'>>
Thanks in Advance.
Upvotes: 0
Views: 2793
Reputation: 2139
To create a dropdown using tableview and popover was little bit time consuming work but luckily we have an alternative solution for that use this library very easy to use
Initialization:
let dropDown = DropDown()
// The view to which the drop down will appear on
dropDown.anchorView = view // UIView or UIBarButtonItem
// The list of items to display. Can be changed dynamically
dropDown.dataSource = ["Car", "Motorcycle", "Truck"]
Handle selection:
// Action triggered on selection
dropDown.selectionAction = { [unowned self] (index: Int, item: String) in
print("Selected item: \(item) at index: \(index)")
}
// Will set a custom width instead of the anchor view width
dropDownLeft.width = 200
Display actions:
dropDown.show()
dropDown.hide()
Hope this will help you
Upvotes: 2