presentViewController from TableViewCell

前端 未结 4 1987

I have a TableViewController, TableViewCell and a ViewController. I have a button in the TableViewCell and I want to present ViewController with presentViewController<

4条回答
  •  旧时难觅i
    2020-12-17 05:43

    You should use protocol to pass the action back to tableViewController

    1) Create a protocol in your cell class

    2) Make the button action call your protocol func

    3) Link your cell's protocol in tableViewController by cell.delegate = self

    4) Implement the cell's protocol and add your code there

    let vc = ViewController()
    self.presentViewController(vc, animated: true, completion: nil)
    

提交回复
热议问题