AssistoLab / DropDown

A Material Design drop down for iOS
MIT License
2.44k stars 625 forks source link

Dropdown doest not show until the keyboad is opened and closed #217

Open bhanushalilinesh opened 5 years ago

bhanushalilinesh commented 5 years ago

I have done everything perfectly but dropdown does not show, when i click on my view dropdown.show code does not execute, but when i open the keyboard and close it and than i click on my view DropDown shows perfectly, below is my code

import DropDown

class ViewController: UIViewController {

@IBOutlet weak var filterButtonView: UIView!

var countryString = ""

let countryDropDown = DropDown()

var countryList:[String] = ["Afghanistan", "Albania"]

override func viewDidLoad() { super.viewDidLoad()

    // Do any additional setup after loading the view.

    self.countryDropDown.anchorView = self.selectCountryView
    self.countryDropDown.dataSource = self.countryList
    self.countryDropDown.direction = .any
    self.countryDropDown.selectionAction = { [unowned self] (index: Int, item: String) in
        print("Selected item: \(item) at index: \(index)")
        self.countryString = item
    }

    self.selectCountryView.isUserInteractionEnabled = true
    let countryTapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.showCountryDropDown))
    self.selectCountryView.addGestureRecognizer(countryTapGesture)
}

@objc func showCountryDropDown() {
    print("Country Clicked")
    self.countryDropDown.show()
}

}

Roman-Markov commented 3 years ago

I found the cause of the similar issue in my side. In project was used UIView extension:

extension UIView {
    func show() {
        if isHidden {

I had to rename it.