[英]How do I make custom action in my tableView cell?
我正在執行自定義操作,該操作執行GitHub存儲庫的動畫。 這是我的具有TableView
的VC代碼:
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
}
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
var done1=UITableViewRowAction(style: .normal, title: "done", handler: UITableViewRowAction!, indexPath: indexPath){
CustomCell.makeanimate(CustomCell)
}
return(done1)
}
這是CustomClass
的代碼:
func makeanimate() {
self.checkTest.setOn(true, animated: true)
}
當我點擊done1
,我想調用makeanimate
,但是我收到一條錯誤消息,稱在'customCell'類型上使用實例成員'makeanimate'
我相信makeanimate
是一個實例方法,但是您在調用它的方式就像在代碼中是類方法一樣。 您需要獲取一個單元實例,然后通過該單元調用makeanimate
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.