首页 > 解决方案 > 将按钮添加到显示另一个模态视图控制器的自定义单元格

问题描述

自定义单元格中,我有一个按钮,我需要以模态方式显示另一个视图控制器现在,通过 func tableView ... didSelectRowAt通常在点击单元格时显示模态视图,但我们希望通过单元格内的特定按钮来执行此操作。

当前代码:TableViewController

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)
    
    if indexPath.section == Section.History.rawValue {
        let viewc = UIStoryboard.checkout.instantiateViewController(withIdentifier: DeliverViewController.identifier) as! DeliverViewController
        viewc.deliveryId = deliveryArray[indexPath.row].id
        viewc.rateDelegate = self
        let nc = UINavigationController(rootViewController: viewc)
        present(nc, animated: true, completion: nil)
    }
}

我想将该动作传递给我的自定义单元类中的 swift 文件中的按钮的 IBAction。谢谢 !!

标签: iosswiftuitableviewuibutton

解决方案


推荐阅读