当我添加此代码时,为什么会出现错误?:
, myProfileWorkoutTableViewCellDelegate
到我的类(class)吗?:
class myProfileTableViewController: UITableViewController, UICollectionViewDataSource, UICollectionViewDelegate, myProfileWorkoutTableViewCellDelegate {
这是我的 myProfileTableViewCell.swift
的开头:
import UIKit
import Firebase
import FirebaseDatabase
protocol myProfileWorkoutTableViewCellDelegate {
func watchTrainingPressed(cell: myProfileWorkoutTableViewCell)
}
class myProfileWorkoutTableViewCell: UITableViewCell {
这是我在单元格内的按钮:
@IBAction func watchTrainingPressed(sender: AnyObject) {
if let _ = delegate {
delegate?.watchTrainingPressed(self)
}
}
最佳答案
您需要实现该功能
func watchTrainingPressed(cell: myProfileWorkoutTableViewCell)
在您的 myProfileTableViewController
类中。
关于ios - 将单元委托(delegate)添加到类时出错 - swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40385412/