셀에 단추가 있고이 단추는 고유 ID가있는보기를 열어야한다는 표보기가 있습니다. 그래서 내 단추에 인수를 전달해야하지만 addTarget
속성을 사용하면 매개 변수없이 함수를 호출 할 수 있습니다.표보기 셀에 단추 대상 추가
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
...
cell.editButton.addTarget(self, action: #selector(goToEdit(id:)), for: .touchUpInside)
}
func goToEdit(id: String) {
let edit = EditAdViewController(editingAdId: id)
self.navigationController?.pushViewController(edit, animated: true)
}
일부 매개 변수가 포함 된 동작을 버튼으로 참조 할 수있는 방법이 있습니까? 모두 감사합니다 :)
https://stackoverflow.com/a/46379494/3746301 – Shades