2017-03-18 3 views
0

나는 GitHub 레포의 애니메이션을 수행하는 커스텀 액션을 만들고있다. 다음은 TableView이 VC의 내 코드입니다 :내 tableView 셀에서 사용자 지정 동작을 수행하려면 어떻게해야합니까?

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를 호출 할

하지만 내가 말하는 오류가 인스턴스 멤버 유형에 'makeanimate'의 사용은 'customCell'나는 makeanimate 생각

답변

0

는 인스턴스 메서드,하지만 당신은 C이다 코드에서 클래스 메서드 인 것처럼 처리 할 수 ​​있습니다. 셀 인스턴스를 가져온 다음 해당 셀을 통해 makeanimate을 호출해야합니다.

+0

어떻게하면됩니까? –

+0

"editActionsForRowAt"메서드에서 indexPath 값을 사용하고자하는 셀에 대한 참조를 얻은 다음 다음과 같이 makeanimate를 호출합니다. cell.makeanimate (CustomCell) – Fahim

+0

'let cell = tableView.dequeueReusableCell (withIdentifier : "CustomCellID")로! CustomCell cell.makeanimate (CustomCell)'? –

관련 문제