Краткий ответ: Да
Длинный ответ:
Ты не должен так поступать. Добавьте жест касания при инициализации ячейки. Таким образом, кран добавляется только один раз при его создании, а не каждый раз, когда он используется повторно.
class CalendarCell: UITableViewCell {
//Your variable declaration and other stuff
.
.
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
//Adding subviews, constraints and other stuff
.
.
.
let locationLabelTap = UITapGestureRecognizer(target: self, action: #selector(locationDidTap(recognizer:)))
locationLabel.addGestureRecognizer(locationLabelTap)
}
.
.
.
}
Если вы используете раскадровку, вы должны сделать то же самое в файле awakeFromNib
, как указано @DuncanC.
override func awakeFromNib() {
super.awakeFromNib()
.
.
.
let locationLabelTap = UITapGestureRecognizer(target: self, action: #selector(locationDidTap(recognizer:)))
locationLabel.addGestureRecognizer(locationLabelTap)
}