There are two views and there were added UIContextMenuInteraction to both views. After tap one of these views need to identify which view was tapped.
class Cell: UITableViewCell {
let redView = UIView()
let blueView = UIView()
...
func setup() {
let interaction1 = UIContextMenuInteraction(delegate: self)
redView.addInteraction(interaction)
let interaction2 = UIContextMenuInteraction(delegate: self)
blueView.addInteraction(interaction)
}
}
extension Cell: UIContextMenuInteractionDelegate {
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { suggestedActions in
// How to here identify which view was tapped
// if tapped redView -> show custom menu1
// if tapped blueView -> show custom menu2
})
}
}
For one views it works fine. But for two ore more views there is difficulties with identifying which view were tapped