AssistoLab / DropDown

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

Dropdown not working in a tableview cell #222

Open alouanemed opened 5 years ago

alouanemed commented 5 years ago

I can't seem to have the dropdown inside a TableView cell, my cell has a stackview as a container, is the reason why it doesn't show the dropdown? Thanks


class ItemCell: TableViewCell {

    override func makeUI() {
        super.makeUI()
        stackView.addArrangedSubview(nextButton)
        stackView.snp.remakeConstraints({ (make) in
            let inset = self.inset
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: inset, left: inset, bottom: inset, right: inset))
        })
        DropDown.setupDefaultAppearance()

        let dropDown = DropDown()
        dropDown.anchorView = nextButton
        dropDown.dataSource = ["Car", "Motorcycle", "Truck"]
        dropDown.direction = .any
        dropDown.bottomOffset = CGPoint(x: 0, y: nextButton.bounds.height)
        dropDown.selectionAction = { [unowned self] (index: Int, item: String) in
            print("Selected item: \(item) at index: \(index)")
        } 
    }

    lazy var nextButton: Button = {
        let view = Button()  
        return view
    }()
}
JustinJusz commented 5 years ago

Hi . I have the same issue. Do you solve this?

alouanemed commented 5 years ago

Unfortunately, not yet.

JustinJusz commented 5 years ago

Please change your code "dropDown.bottomOffset = CGPoint(x: 0, y: nextButton.bounds.height)" to dropDown.topOffset = CGPoint(x: 0, y:-(self.dropDown.anchorView?.plainView.bounds.height)!)...may be its works. I've solve my issue