gpt4 book ai didi

iOS TableView 长按手势去 didselectrowatIndexpath

转载 作者:行者123 更新时间:2023-12-01 15:47:36 25 4
gpt4 key购买 nike

伙计们,我有显示图像的表格 View ,因此对于任何图像,点击都会在

中打开图像

didselectrowatIndexpath

所以我想添加一个长按手势所以我添加了

let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressed(_:))) 
cell.baseview.addGestureRecognizer(longPressGesture)

但每次我按住图像时,它都会使用 didselectrowat 方法打开图像,而不是使用长按方法。对于长按手势 Action ,我应该改变什么吗?

最佳答案

这是 Apple 对您问题的回答。

Managing Selections (Responding to Selections)
If the touch occurred in a control embedded in the row, it couldrespond to the action message sent by the control.

Understanding Responders and the Responder Chain
UIKit directs most events to the most appropriate responder object in your app. If that object does not handle the event, UIKit forwards it to the next responder in the active responder chain, which is a dynamic configuration of your app’s responder objects.

解决方案:
您在图像的用户交互方面存在问题。在 ImageView 上启用用户交互。

cell.baseview.isUserInteractionEnabled = true

关于iOS TableView 长按手势去 didselectrowatIndexpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45608089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com