Как сделать элементы нижнего колонтитула Xib интерактивными в tableView Swift - PullRequest
0 голосов
/ 06 мая 2020

Я изо всех сил пытаюсь сделать элементы нижнего колонтитула интерактивными в tableView. В tableView я использую два разных Xib, и я использовал tableView - didSelect function в качестве расширяемой ячейки при нажатии.

1) Основной Xib

2) Child_View - Footer Xib

Теперь в элементах нижнего колонтитула, которые являются childView - я также хочу сделать кликабельное действие, поэтому при нажатии на него будет navigate to viewController с их подробной информацией.

  • Как я могу этого добиться, потому что didSelect уже используется для расширяемых ячеек?

Присоединение трех изображений

  • Main Xib
  • Расширенный - элементы нижнего колонтитула (второй Xib)
  • Выделенный элемент должен быть интерактивным

объявить: var selectedIndex : Int! = -1

Код:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.row == selectedIndex{
            selectedIndex = -1

        }else{
            selectedIndex = indexPath.row
        }
        tableView.reloadData()
    }

    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.row == selectedIndex
        {
            return UITableView.automaticDimension
        }else{
            return 71
        }
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return 1 
    }


    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "DownloadEntryViewCell", for: indexPath) as! DownloadEntryViewCell
        let dic = Appdata?[indexPath.row]
        var stackHeight:CGFloat = 0.0
        cell.fileNameLabel.text = dic?.date

        for i in Appdata ?? [] {
            let child_view = Bundle.main.loadNibNamed("FooterView", owner: self, options: nil)?.first as! FooterView
            child_view.projName.text = "\(i.projectName ?? "")" + "  " + "\(i.subTitle ?? "")"

            cell.stackViewFooter.addArrangedSubview(child_view)
            stackHeight = stackHeight + 60.0

        }
        cell.stackViewFooter.heightAnchor.constraint(equalToConstant: stackHeight).isActive = true
        return cell
    }

Изображения:

Основное Расширяемое кликабельное

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...