1

我正在处理UITableView一个自定义行(单行),我从一个单独的xib文件加载。UITableView也有粘性footer view

一切正常,除了当我点击 时footer viewUITableView's委托方法tableView(_:didSelectRowAt:)被调用,这很奇怪。

我在该IndexPath方法中收到的是 [0,0]。现在这对我有什么问题?好吧,当按下该表格视图的单元格时,我正在做某件事。但是在当前情况下,当我按下页脚视图而不是单元格时,也会完成某些事情。

UITableView 的代码是:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    guard let cell = tableView.dequeueReusableCell(
        withIdentifier: CellIdentifiers.INVITE_CELL_ID,
        for: indexPath) as? InviteCell else {

        return UITableViewCell()
    }

    // cell configuration

    return cell
}

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {

    if (contacts.count > 0) {

        guard let footer = tableView.dequeueReusableCell(
            withIdentifier: CellIdentifiers.INVITE_FOOTER_CELL_ID)
            as? InviteFooter else {

                return nil
        }

        footer.delegate = self

        return footer
    }
    return nil
}

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

    if (contacts.count > 0) {
        return 90
    }
    return 0
}
4

0 回答 0