What you can do actually, there are two common practice to have control on ViewCels, since those are views you can simply create and extensions to make your work time less. For example;
//This enum can be extended due to demand
enum GestureRecognizerType {
case Tap
case Pinch
case Rotate
}
extension UIView {
func addRecognizer(_ gType:GestureRecognizerType, handleGesture:Selector, _ controller:UIViewController){
var recognizer:UIGestureRecognizer!
switch gType {
case .Pinch:
recognizer = UIPinchGestureRecognizer(target: controller, action: handleGesture)
case .Rotate:
recognizer = UIRotationGestureRecognizer(target: controller, action: handleGesture)
case .Tap:
recognizer = UITapGestureRecognizer(target: controller, action: handleGesture)
}
self.addGestureRecognizer(recognizer)
}
Then call wherever you want to. Usage could be like:
override func viewDidLoad(){
super.viewDidLoad
let view = UIView()
view.addRecognizer(.Tap, handleGesture: #selector(handleTap(_:)), self)
}
@objc func handleTap(_ recognizer:UITapGestureRecognizer){
//Handle when the view tapped
}
The other practice could be handle all inside of your custom cell Class and give them recognisers when they are set using didSet.