按钮,当我上下滚动表格视图时,标签隐藏起来

时间:2018-07-30 11:14:12

标签: ios swift tableview

我有一个<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="animate-text"> <p class="first-text">HTML</p><br> </div>,在每个单元格中我都有一个tableview,称为下拉列表。因此,当用户按下我的下拉菜单中的任何选项时,隐藏的元素(例如一个下拉菜单,一个名称标签和一个保存按钮)将可见。因此,当用户再次按下我的保存按钮时,这些元素将被隐藏。现在的问题是,当我在两个或三个单元格中选择按钮时,以及如果我自动上下滚动哪个和所有单元格都将显示隐藏的元素。我需要显示单击的所有单元格并显示元素。

button

2 个答案:

答案 0 :(得分:0)

隐藏按钮后,除非您明确将其隐藏,否则它将永远不会被隐藏。

“现在的问题是,当我在两个或三个单元格中选择我的按钮,并且如果我自动上下滚动时,哪个以​​及所有单元格都显示出隐藏的元素”

让单元格= tableView.dequeueReusableCell(withIdentifier:“ CartDetailsCell”,for:indexPath)为! CartDetailsCell

在使用带有隐藏按钮的单元格时,将使按钮对于其余单元格保持隐藏状态

答案 1 :(得分:0)

我建议使用以下模式,这将节省您的时间,并且您将获得更可重用和更漂亮的代码:

protocol CartDetailsCellDelegate: class {
    func didTouchDropDownButton(in cell: CartDetailsCell)
    ....
}

final class CartDetailsCell: UITableViewCell {
    ....
    weak var delegate: CartDetailsCellDelegate?

    @IBAction func didTouchDropDownButton(_ sender: UIButton) {
        delegate?.didTouchDropDownButton(in: self)
    }
    ...
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    ...
    cell.delegate = self
    ...
}

extension ViewController: CartDetailsCellDelegate {
    func didTouchDropDownButton(in cell: CartDetailsCell) {
        // Do your stuff here, you have the cell, don't have to play with tags
    }
}
相关问题