我在uitableviewcell中有一个UIButton,它在主要的StoryBoard中设置了“show segue”。我想按下此按钮并执行新的控制器,那么我该怎么做呢?
//有很多方法可以做到这一点://取tableviewcell中的按钮插座
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell2 : cellname = tableView.dequeueReusableCell(withIdentifier: "cellname") as! cellname
cell2.addAddressButton.addTarget(self, action: #selector(openNewVC), for: .touchUpInside)
return cell2
}
func openNewVC(){
self.performSegue(withIdentifier: "Identifiername", sender: self)
}
请在tableview单元格中使用自定义委托,
请按照以下链接,
https://medium.com/@jamesrochabrun/implementing-delegates-in-swift-step-by-step-d3211cbac3ef
现在,在视图控制器中,内部委托函数使用
performSegue(withIdentifier: "identifier", sender: self)