presentViewController from TableViewCell

前端 未结 4 1980

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

4条回答
  •  既然无缘
    2020-12-17 05:56

    So self.presentViewController is a method from the ViewController. The reason you are getting this error is because the "self" you are referring is the tableViewCell. And tableViewCell doesn't have method of presentViewController.

    I think there are some options you can use: 1.add a delegate and protocol in the cell, when you click on the button, the IBAction will call

    self.delegate?.didClickButton()
    

    Then in your tableVC, you just need to implement this method and call self.presentViewController

    2.use a storyboard and a segue In the storyboard, drag from your button to the VC you want to go.

提交回复
热议问题