如何在 UIImageView 上设置 UIGestureRecognizer?
如何添加 UIGestureRecognizer 来识别 UIImageView 顶部的向左或向右滑动?我只需要在向左滑动时调用一个操作,在向右滑动时调用另一个操作。
How can I add a UIGestureRecognizer to recognise left or right swipes on top of a UIImageView? I just need an action to be called when the swipe is left and another action for when the swipe is right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建 2 个滑动手势并将它们添加到您的图像视图中。
Create 2 swipe gestures and add them to your image view.
是否设置
在附加
UIGestureRecognizer
之前为 true?如果不尝试,
如果这不起作用,您可以添加一个临时视图并将手势识别器添加到临时视图,然后将图像视图添加到临时视图
Have you set
to true before you attach the
UIGestureRecognizer
?If not try that
If that doesn't work, you could add a temp view and add the gesture recognizer to the temp view and then add the imageview to the temp view