AssistoLab/DropDown

Dropdown not working in a tableview cell

Opened this issue · 3 comments

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

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

Unfortunately, not yet.

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