Skip to content

Commit

Permalink
[#10] tableView cell 이미지에 tapGestureRecognizer 넣기
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwns33 committed Dec 24, 2021
1 parent 72a8ebe commit 66eb8c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 29th_Youtube/29th_Youtube/Sources/HomeVC/Cell/ContentTVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ContentTVC: UITableViewCell {

static let identifier = "ContentTVC"

var presentToDetailViewController: (() -> Void)?

override func awakeFromNib() {
super.awakeFromNib()
setUI()
Expand All @@ -28,10 +30,21 @@ class ContentTVC: UITableViewCell {
func setUI(){
descriptions.text = "WE SOPT : 조회수 100만회 : 3주 전"
descriptions.textColor = .darkGray
let tapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
tapGesture.delegate = self

thumbnail.isUserInteractionEnabled = true
thumbnail.addGestureRecognizer(tapGesture)
}

func setData(contentData: ContentData) {
thumbnail.image = contentData.makeImage()
title.text = contentData.contentTitle
}

@objc func handleTap(_ sender: UITapGestureRecognizer? = nil) {
presentToDetailViewController?()
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ extension HomeXibVC: UITableViewDataSource{
guard let cell = tableView.dequeueReusableCell(withIdentifier: ContentTVC.identifier) as? ContentTVC else {return UITableViewCell()}

cell.setData(contentData: contentList[indexPath.row])
cell.presentToDetailViewController = {
// 디테일로 이동
}
return cell
}
}
Expand Down

0 comments on commit 66eb8c6

Please sign in to comment.