Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let dn = arrData[indexPath.row]
- cell.fav_btn.tag = dn.id
- cell.fav_btn.addTarget(self, action: #selector(checkMarkButtonClicked(sender:)), for: .touchUpInside)
- }
- @objc func checkMarkButtonClicked ( sender: UIButton) {
- print("button presed")
- let buttonTag = sender.tag
- print(buttonTag)
- }
- class CustomTableViewCell: UITableViewCell {
- var buttonAction: (() -> Void)?
- }
- fav_btn.addTarget(self, action: #selector(checkMarkButtonClicked(sender:)), for: .touchUpInside)
- @objc func checkMarkButtonClicked (sender: UIButton) {
- if let myAction = buttonAction {
- myAction()
- }
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- // ваша логика
- cell.buttonAction = { [weak self] in
- self?.someMethod()
- }
- }
Add Comment
Please, Sign In to add comment